Flow123d
JS_before_hm-2081-g08ad9c456
src
intersection
plucker.cc
Go to the documentation of this file.
1
#include "
plucker.hh
"
2
3
using namespace
std
;
4
5
Plucker::Plucker
()
6
: coordinates_({0,0,0,0,0,0}),
7
scale_(0),
8
computed_(
false
),
9
points_(3, 1, 2)
10
{}
11
12
13
Plucker::Plucker
(
Point
a,
Point
b)
14
:
Plucker
()
15
{
16
points_
.
set
(0) = a;
17
points_
.
set
(1) = b;
18
coordinates_
(arma::span(0,2)) =
point
(1) -
point
(0);
19
20
// Check empty
21
ASSERT_DBG
(arma::norm(
coordinates_
(arma::span(0,2)),2) > 0);
22
23
scale_
= 0;
24
scale_
= std::max(
scale_
, std::fabs(
coordinates_
[0]));
25
scale_
= std::max(
scale_
, std::fabs(
coordinates_
[1]));
26
scale_
= std::max(
scale_
, std::fabs(
coordinates_
[2]));
27
28
computed_
=
false
;
29
}
30
31
Plucker::Plucker
(
Point
a,
Point
b,
bool
compute_pc)
32
:
Plucker
(a,b)
33
{
34
if
(compute_pc)
compute
();
35
}
36
37
38
double
Plucker::operator*
(
const
Plucker
&b){
39
return
(
coordinates_
[0]*b[3]) + (
coordinates_
[1]*b[4]) + (
coordinates_
[2]*b[5]) + (
coordinates_
[3]*b[0]) + (
coordinates_
[4]*b[1]) +(
coordinates_
[5]*b[2]);
40
}
41
42
43
void
Plucker::compute
(){
44
if
(
computed_
)
return
;
45
46
coordinates_
[3] =
coordinates_
[1]*
point
(0)[2] -
coordinates_
[2]*
point
(0)[1];
47
coordinates_
[4] =
coordinates_
[2]*
point
(0)[0] -
coordinates_
[0]*
point
(0)[2];
48
coordinates_
[5] =
coordinates_
[0]*
point
(0)[1] -
coordinates_
[1]*
point
(0)[0];
49
computed_
=
true
;
50
}
51
52
ostream&
operator<<
(ostream& os,
const
Plucker
& p)
53
{
54
if
(p.
computed_
){
55
os <<
"("
<< p.
coordinates_
[0] <<
","
<< p.
coordinates_
[1] <<
","
<< p.
coordinates_
[2] <<
","
56
<< p.
coordinates_
[3] <<
","
<< p.
coordinates_
[4] <<
","
<< p.
coordinates_
[5] <<
")"
;
57
}
else
{
58
os <<
"NULL (Plucker coords have not been computed)"
;
59
}
60
return
os;
61
}
62
63
Plucker::Point
Space< 3 >::Point Point
Definition:
plucker.hh:54
Plucker
Plucker coordinates representing line given by points A,B.
Definition:
plucker.hh:45
Plucker::point
arma::vec3 point(unsigned int idx) const
Gets coordinates of point.
Definition:
plucker.hh:123
Plucker::operator*
double operator*(const Plucker &b)
Compute product of two Plucker coordinates.
Definition:
plucker.cc:38
ASSERT_DBG
#define ASSERT_DBG(expr)
Definition:
include_fadbad.hh:28
Plucker::computed_
bool computed_
True, if Plucker coordinates are computed; false otherwise.
Definition:
plucker.hh:50
plucker.hh
Plucker coordinates class.
Armor::Array::set
ArrayMatSet set(uint index)
Definition:
armor.hh:838
Plucker::points_
Armor::Array< double > points_
Definition:
plucker.hh:51
Plucker::Plucker
Plucker()
Definition:
plucker.cc:5
Plucker::compute
void compute()
Compute Plucker coordinates and set computed to true.
Definition:
plucker.cc:43
std
Definition:
doxy_dummy_defs.hh:5
Plucker::coordinates_
arma::vec6 coordinates_
Plucker coordinates.
Definition:
plucker.hh:48
Plucker::scale_
double scale_
Definition:
plucker.hh:49
operator<<
ostream & operator<<(ostream &os, const Plucker &p)
Operator for printing Plucker coordinates.
Definition:
plucker.cc:52
Generated by
1.8.17