Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JGEOMETRY3D::JSegment3D Class Reference

Line segment in two dimensions. More...

#include <JSegment3D.hh>

Inheritance diagram for JGEOMETRY3D::JSegment3D:
std::pair< JFirst_t, JSecond_t >

Public Member Functions

 JSegment3D ()
 Default constructor.
 
 JSegment3D (const JVector3D &A, const JVector3D &B)
 Constructor.
 
double getLengthSquared () const
 Get length squared.
 
double getLength () const
 Get length.
 
double getDistanceSquared (const JVector3D &point, const double precision=1.0e-8) const
 Get squared of distance to point.
 
double getDistance (const JVector3D &point) const
 Get distance to point.
 
double getDot (const JSegment3D &segment) const
 Get dot product.
 

Friends

JReaderoperator>> (JReader &in, JSegment3D &segment)
 Read segment from input.
 
JWriteroperator<< (JWriter &out, const JSegment3D &segment)
 Write segment to output.
 

Detailed Description

Line segment in two dimensions.

Definition at line 33 of file JSegment3D.hh.

Constructor & Destructor Documentation

◆ JSegment3D() [1/2]

JGEOMETRY3D::JSegment3D::JSegment3D ( )
inline

Default constructor.

Definition at line 40 of file JSegment3D.hh.

40 :
42 {}
std::pair< JPosition3D, JPosition3D > JSegment3D_t
Type definition of line segment in two dimensions.
Definition JSegment3D.hh:27

◆ JSegment3D() [2/2]

JGEOMETRY3D::JSegment3D::JSegment3D ( const JVector3D & A,
const JVector3D & B )
inline

Constructor.

Parameters
Astart position
Bend position

Definition at line 51 of file JSegment3D.hh.

52 :
53 JSegment3D_t(A,B)
54 {}

Member Function Documentation

◆ getLengthSquared()

double JGEOMETRY3D::JSegment3D::getLengthSquared ( ) const
inline

Get length squared.

Returns
square of length

Definition at line 62 of file JSegment3D.hh.

63 {
64 return JVector3D(this->second - this->first).getLengthSquared();
65 }

◆ getLength()

double JGEOMETRY3D::JSegment3D::getLength ( ) const
inline

Get length.

Returns
length

Definition at line 73 of file JSegment3D.hh.

74 {
75 return sqrt(getLengthSquared());
76 }
double getLengthSquared() const
Get length squared.
Definition JSegment3D.hh:62

◆ getDistanceSquared()

double JGEOMETRY3D::JSegment3D::getDistanceSquared ( const JVector3D & point,
const double precision = 1.0e-8 ) const
inline

Get squared of distance to point.

Parameters
pointpoint
precisionprecision
Returns
square of distance

Definition at line 86 of file JSegment3D.hh.

87 {
88 JVector3D D(this->second - this->first);
89
90 const double gp = D.getLengthSquared();
91
92 if (gp > precision) {
93
94 const JVector3D U(point - this->first);
95
96 double u = D.getDot(U);
97
98 if (u < 0.0)
99 u = 0.0;
100 else if (u > gp)
101 u = 1.0;
102 else
103 u /= gp;
104
105 D.mul(u);
106 D.sub(U);
107
108 return D.getLengthSquared();
109
110 } else {
111
112 return this->first.getDistanceSquared(point);
113 }
114 }

◆ getDistance()

double JGEOMETRY3D::JSegment3D::getDistance ( const JVector3D & point) const
inline

Get distance to point.

Parameters
pointpoint
Returns
distance

Definition at line 123 of file JSegment3D.hh.

124 {
125 return sqrt(getDistanceSquared(point));
126 }
double getDistanceSquared(const JVector3D &point, const double precision=1.0e-8) const
Get squared of distance to point.
Definition JSegment3D.hh:86

◆ getDot()

double JGEOMETRY3D::JSegment3D::getDot ( const JSegment3D & segment) const
inline

Get dot product.

Parameters
segmentsegment
Returns
dot product

Definition at line 135 of file JSegment3D.hh.

136 {
137 return JVector3D(this->second - this->first).getDot(segment.second - segment.first);
138 }

Friends And Related Symbol Documentation

◆ operator>>

JReader & operator>> ( JReader & in,
JSegment3D & segment )
friend

Read segment from input.

Parameters
inreader
segmentsegment
Returns
reader

Definition at line 148 of file JSegment3D.hh.

149 {
150 in >> segment.first;
151 in >> segment.second;
152
153 return in;
154 }

◆ operator<<

JWriter & operator<< ( JWriter & out,
const JSegment3D & segment )
friend

Write segment to output.

Parameters
outwriter
segmentsegment
Returns
writer

Definition at line 164 of file JSegment3D.hh.

165 {
166 out << segment.first;
167 out << segment.second;
168
169 return out;
170 }

The documentation for this class was generated from the following file: