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

Cylinder object. More...

#include <JCylinder3D.hh>

Inheritance diagram for JGEOMETRY3D::JCylinder3D:
JGEOMETRY2D::JCircle2D JGEOMETRY2D::JPosition2D JGEOMETRY2D::JVector2D JMATH::JMath< JFirst_t, JSecond_t >

Public Types

typedef std::pair< double, double > intersection_type
 Type definition of intersection.
 

Public Member Functions

 JCylinder3D ()
 Default constructor.
 
 JCylinder3D (const JCircle2D &circle, const double zmin, const double zmax)
 Constructor.
 
template<class T >
 JCylinder3D (T __begin, T __end, const double precision=std::numeric_limits< double >::epsilon())
 Constructor.
 
double getZmin () const
 Get minimal z position.
 
double getZmax () const
 Get maximal z position.
 
void setZmin (const double zmin)
 Set minimal z position.
 
void setZmax (const double zmax)
 Set maximal z position.
 
JCylinder3Dadd (const JVector3D &pos)
 Add position.
 
void addMargin (const double D)
 Add (safety) margin.
 
double getVolume () const
 Get volume.
 
JPosition3D getCenter () const
 Get centre.
 
bool is_inside (const JVector3D &pos) const
 Check whether given point is inside cylinder.
 
double getDistance (const JVector3D &pos) const
 Get distance between cylinder wall and given position.
 
double getDistanceSquared (const JVector3D &pos) const
 Get square of distance between cylinder wall and given position.
 
intersection_type getIntersection (const JAxis3D &axis) const
 Get intersection points of axis with cylinder.
 
double getRadius () const
 Get radius.
 
void set (const JVector2D &p0, const JVector2D &p1)
 Set circle.
 
void set (const JVector2D &p0, const JVector2D &p1, const JVector2D &p2, const double precision=std::numeric_limits< double >::epsilon())
 Set circle.
 
template<class T >
void set (T __begin, T __end, const double precision=std::numeric_limits< double >::epsilon())
 Set circle.
 
bool is_inside (const JVector2D &pos, const double precision=std::numeric_limits< double >::min()) const
 Check whether given point is inside circle.
 
const JPosition2DgetPosition () const
 Get position.
 
JPosition2DgetPosition ()
 Get position.
 
void setPosition (const JVector2D &pos)
 Set position.
 
 operator JAngle2D () const
 Type conversion operator.
 
 operator JVersor2D () const
 Type conversion operator.
 
JPosition2Drotate (const JRotation2D &R)
 Rotate.
 
JPosition2Drotate_back (const JRotation2D &R)
 Rotate back.
 
double getDot (const JAngle2D &angle) const
 Get dot product.
 
double getDot (const JVersor2D &versor) const
 Get dot product.
 
double getDot (const JVector2D &point) const
 Get dot product.
 
double getPerpDot (const JAngle2D &angle) const
 Get perpendicular dot product.
 
double getPerpDot (const JVersor2D &dir) const
 Get perpendicular dot product.
 
double getPerpDot (const JVector2D &point) const
 Get perpendicular dot product.
 
JVector2Dtransform (const JMatrix2D &T)
 Transform.
 
double getX () const
 Get x position.
 
double getY () const
 Get y position.
 
JVector2Dnegate ()
 Negate vector.
 
JVector2Dadd (const JVector2D &vector)
 Add vector.
 
JVector2Dsub (const JVector2D &vector)
 Subtract vector.
 
JVector2Dmul (const double factor)
 Scale vector.
 
JFirst_t & mul (const JSecond_t &object)
 Multiply with object.
 
JVector2Ddiv (const double factor)
 Scale vector.
 
bool equals (const JVector2D &vector, const double precision=std::numeric_limits< double >::min()) const
 Check equality.
 
double getLengthSquared () const
 Get length squared.
 
double getLength () const
 Get length.
 
double getDistanceSquared (const JVector2D &point) const
 Get squared of distance to point.
 
double getDistance (const JVector2D &point) const
 Get distance to point.
 

Protected Attributes

double zmin
 
double zmax
 
double __r
 
double __x
 
double __y
 

Private Member Functions

template<class T >
void configure (T __begin, T __end, const JVector2D &p0, const double precision)
 Determine smallest enclosing circle.
 
template<class T >
void configure (T __begin, T __end, const JVector2D &p0, const JVector2D &p1, const double precision)
 Determine smallest enclosing circle.
 

Friends

std::istream & operator>> (std::istream &in, JCylinder3D &cylinder)
 Read cylinder from input stream.
 
std::ostream & operator<< (std::ostream &out, const JCylinder3D &cylinder)
 Write cylinder to output stream.
 
JReaderoperator>> (JReader &in, JCylinder3D &cylinder)
 Read cylinder from input.
 
JWriteroperator<< (JWriter &out, const JCylinder3D &cylinder)
 Write cylinder to output.
 

Detailed Description

Cylinder object.

The cylinder consists of a 2D circle in the (x,y) plane and a range in z (i.e. axis of cylinder is parallel to the z-axis).

Definition at line 39 of file JCylinder3D.hh.

Member Typedef Documentation

◆ intersection_type

Type definition of intersection.

Definition at line 46 of file JCylinder3D.hh.

Constructor & Destructor Documentation

◆ JCylinder3D() [1/3]

JGEOMETRY3D::JCylinder3D::JCylinder3D ( )
inline

Default constructor.

Definition at line 52 of file JCylinder3D.hh.

52 :
53 JCircle2D(),
54 zmin(0.0),
55 zmax(0.0)
56 {}
JCircle2D()
Default constructor.
Definition JCircle2D.hh:40

◆ JCylinder3D() [2/3]

JGEOMETRY3D::JCylinder3D::JCylinder3D ( const JCircle2D & circle,
const double zmin,
const double zmax )
inline

Constructor.

Parameters
circle2D circle in (x,y)
zminminimal z
zmaxmaximal z

Definition at line 66 of file JCylinder3D.hh.

68 :
69 JCircle2D(circle)
70 {
71 this->zmin = zmin;
72 this->zmax = zmax;
73 }

◆ JCylinder3D() [3/3]

template<class T >
JGEOMETRY3D::JCylinder3D::JCylinder3D ( T __begin,
T __end,
const double precision = std::numeric_limits<double>::epsilon() )
inline

Constructor.

Determines smallest enclosing cylinder for any number of points.

Parameters
__beginbegin of data
__endend of data
precisionprecision

Definition at line 86 of file JCylinder3D.hh.

88 :
89 JCircle2D(__begin, __end, precision),
90 zmin(0.0),
91 zmax(0.0)
92 {
93 if (__begin != __end) {
94
95 zmin = std::numeric_limits<double>::max();
96 zmax = std::numeric_limits<double>::lowest();
97
98 for (T i = __begin; i != __end; ++i) {
99 if (i->getZ() < zmin) zmin = i->getZ();
100 if (i->getZ() > zmax) zmax = i->getZ();
101 }
102 }
103 }

Member Function Documentation

◆ getZmin()

double JGEOMETRY3D::JCylinder3D::getZmin ( ) const
inline

Get minimal z position.

Returns
minimal z position

Definition at line 111 of file JCylinder3D.hh.

112 {
113 return zmin;
114 }

◆ getZmax()

double JGEOMETRY3D::JCylinder3D::getZmax ( ) const
inline

Get maximal z position.

Returns
maximal z position

Definition at line 122 of file JCylinder3D.hh.

123 {
124 return zmax;
125 }

◆ setZmin()

void JGEOMETRY3D::JCylinder3D::setZmin ( const double zmin)
inline

Set minimal z position.

Parameters
zminminimal z position

Definition at line 133 of file JCylinder3D.hh.

134 {
135 this->zmin = zmin;
136 }

◆ setZmax()

void JGEOMETRY3D::JCylinder3D::setZmax ( const double zmax)
inline

Set maximal z position.

Parameters
zmaxmaximal z position

Definition at line 144 of file JCylinder3D.hh.

145 {
146 this->zmax = zmax;
147 }

◆ add() [1/2]

JCylinder3D & JGEOMETRY3D::JCylinder3D::add ( const JVector3D & pos)
inline

Add position.

Parameters
posposition
Returns
this cylinder

Definition at line 156 of file JCylinder3D.hh.

157 {
158 static_cast<JPosition2D&>(*this).add(JPosition2D(pos.getX(), pos.getY()));
159
160 zmin += pos.getZ();
161 zmax += pos.getZ();
162
163 return *this;
164 }
JPosition2D()
Default constructor.

◆ addMargin()

void JGEOMETRY3D::JCylinder3D::addMargin ( const double D)
inline

Add (safety) margin.

Parameters
Dmargin

Definition at line 172 of file JCylinder3D.hh.

173 {
174 __r += D;
175 zmin -= D;
176 zmax += D;
177 }

◆ getVolume()

double JGEOMETRY3D::JCylinder3D::getVolume ( ) const
inline

Get volume.

Returns
volume

Definition at line 185 of file JCylinder3D.hh.

186 {
187 return (getZmax() - getZmin()) * JMATH::PI * getRadius() * getRadius();
188 }
double getRadius() const
Get radius.
Definition JCircle2D.hh:144
double getZmin() const
Get minimal z position.
double getZmax() const
Get maximal z position.
static const double PI
Mathematical constants.

◆ getCenter()

JPosition3D JGEOMETRY3D::JCylinder3D::getCenter ( ) const
inline

Get centre.

Returns
centre

Definition at line 196 of file JCylinder3D.hh.

197 {
198 return JPosition3D(getPosition(), (getZmax() - getZmin())/2.0);
199 }
const JPosition2D & getPosition() const
Get position.

◆ is_inside() [1/2]

bool JGEOMETRY3D::JCylinder3D::is_inside ( const JVector3D & pos) const
inline

Check whether given point is inside cylinder.

Parameters
posposition
Returns
true if inside; else false

Definition at line 208 of file JCylinder3D.hh.

209 {
210 return (pos.getZ() >= getZmin() &&
211 pos.getZ() <= getZmax() &&
212 JCircle2D::is_inside(JVector2D(pos.getX(), pos.getY())));
213 }
bool is_inside(const JVector2D &pos, const double precision=std::numeric_limits< double >::min()) const
Check whether given point is inside circle.
Definition JCircle2D.hh:270
JVector2D()
Default constructor.
Definition JVector2D.hh:39

◆ getDistance() [1/2]

double JGEOMETRY3D::JCylinder3D::getDistance ( const JVector3D & pos) const
inline

Get distance between cylinder wall and given position.

Parameters
posposition
Returns
distance

Definition at line 222 of file JCylinder3D.hh.

223 {
224 JVector2D D(pos);
225
226 D.sub(*this);
227
228 double R = D.getLength();
229
230 if (R > this->getRadius()) {
231
232 R -= this->getRadius();
233
234 double dz = 0.0;
235
236 if (pos.getZ() > this->getZmax())
237 dz = pos.getZ() - this->getZmax();
238 else if (pos.getZ() < this->getZmin())
239 dz = this->getZmin() - pos.getZ();
240 else
241 return R;
242
243 return sqrt(R*R + dz*dz);
244
245 } else {
246
247 if (pos.getZ() > this->getZmax())
248 return pos.getZ() - this->getZmax();
249 else if (pos.getZ() < this->getZmin())
250 return this->getZmin() - pos.getZ();
251 else
252 return 0.0;
253 }
254 }

◆ getDistanceSquared() [1/2]

double JGEOMETRY3D::JCylinder3D::getDistanceSquared ( const JVector3D & pos) const
inline

Get square of distance between cylinder wall and given position.

Parameters
posposition
Returns
square of distance

Definition at line 263 of file JCylinder3D.hh.

264 {
265 const double d = getDistance(pos);
266
267 return d*d;
268 }
double getDistance(const JVector3D &pos) const
Get distance between cylinder wall and given position.

◆ getIntersection()

intersection_type JGEOMETRY3D::JCylinder3D::getIntersection ( const JAxis3D & axis) const
inline

Get intersection points of axis with cylinder.

Parameters
axisaxis
Returns
up and down stream positions along axis

Definition at line 277 of file JCylinder3D.hh.

278 {
279 double path[] = { 0.0, 0.0 };
280
281 if (fabs(axis.getDZ()) != 0.0) {
282
283 // intersection with bottom or top surface
284
285 const double Z[] = {
286 axis.getDZ() > 0 ? this->getZmin() : this->getZmax(),
287 axis.getDZ() > 0 ? this->getZmax() : this->getZmin()
288 };
289
290 for (int i = 0; i != 2; ++i) {
291
292 const double u = (Z[i] - axis.getZ()) / axis.getDZ();
293 const double x = axis.getX() + u * axis.getDX() - this->getX();
294 const double y = axis.getY() + u * axis.getDY() - this->getY();
295
296 if (x*x + y*y <= this->getRadius() * this->getRadius()) {
297 path[i] = u;
298 }
299 }
300 }
301
302 if (fabs(axis.getDZ()) != 1.0) {
303
304 // intersection with cylinder wall
305
306 const double x = axis.getX() - this->getX();
307 const double y = axis.getY() - this->getY();
308 const double dx = axis.getDX();
309 const double dy = axis.getDY();
310 const double R = this->getRadius();
311
312 const double a = (dx * dx + dy * dy);
313 const double b = 2*(dx * x + dy * y);
314 const double c = (x * x + y * y) - R * R;
315
316 const double q = b*b - 4*a*c;
317
318 if (q >= 0) {
319
320 const double u[] = {
321 (-b - sqrt(q)) / (2*a),
322 (-b + sqrt(q)) / (2*a)
323 };
324
325 for (int i = 0; i != 2; ++i) {
326
327 const double z = axis.getZ() + u[i] * axis.getDZ();
328
329 if (z >= this->getZmin() && z <= this->getZmax()) {
330 path[i] = u[i];
331 }
332 }
333 }
334 }
335
336 return std::minmax(path[0], path[1]);
337 }
double getY() const
Get y position.
Definition JVector2D.hh:74
double getX() const
Get x position.
Definition JVector2D.hh:63
const double a

◆ getRadius()

double JGEOMETRY2D::JCircle2D::getRadius ( ) const
inlineinherited

Get radius.

Returns
radius

Definition at line 144 of file JCircle2D.hh.

145 {
146 return __r;
147 }

◆ set() [1/3]

void JGEOMETRY2D::JCircle2D::set ( const JVector2D & p0,
const JVector2D & p1 )
inlineinherited

Set circle.

Determines circle through two points.

Parameters
p0first point
p1second point

Definition at line 157 of file JCircle2D.hh.

159 {
160 __x = 0.5 * (p0.getX() + p1.getX());
161 __y = 0.5 * (p0.getY() + p1.getY());
162 __r = this->getDistance(p0);
163 }
TPaveText * p1
double getDistance(const JVector2D &point) const
Get distance to point.
Definition JVector2D.hh:223

◆ set() [2/3]

void JGEOMETRY2D::JCircle2D::set ( const JVector2D & p0,
const JVector2D & p1,
const JVector2D & p2,
const double precision = std::numeric_limits<double>::epsilon() )
inlineinherited

Set circle.

Determines circle through three points.

Parameters
p0first point
p1second point
p2third point
precisionprecision

Definition at line 175 of file JCircle2D.hh.

179 {
180 const double x0 = p2.getX() - p1.getX();
181 const double x1 = p0.getX() - p2.getX();
182 const double x2 = p1.getX() - p0.getX();
183
184 const double y0 = p1.getY() - p2.getY();
185 const double y1 = p2.getY() - p0.getY();
186 const double y2 = p0.getY() - p1.getY();
187
188 const double D = 2.0 * (p0.getX()*y0 + p1.getX()*y1 + p2.getX()*y2);
189
190 if (fabs(D) > precision) {
191
192 const double a = p0.getLengthSquared();
193 const double b = p1.getLengthSquared();
194 const double c = p2.getLengthSquared();
195
196 __x = (a*y0 + b*y1 + c*y2) / D;
197 __y = (a*x0 + b*x1 + c*x2) / D;
198 __r = this->getDistance(p0);
199
200 } else {
201
202 set(p0, p1);
203
204 const JCircle2D c1(p1, p2);
205 const JCircle2D c2(p0, p2);
206
207 if (c1.getRadius() > this->getRadius()) { *this = c1; }
208 if (c2.getRadius() > this->getRadius()) { *this = c2; }
209 }
210 }
TCanvas * c1
Global variables to handle mouse events.
void set(const JVector2D &p0, const JVector2D &p1)
Set circle.
Definition JCircle2D.hh:157

◆ set() [3/3]

template<class T >
void JGEOMETRY2D::JCircle2D::set ( T __begin,
T __end,
const double precision = std::numeric_limits<double>::epsilon() )
inlineinherited

Set circle.

Determines smallest enclosing circle around set of points.

    double getX();   // x coordinate
    double getY();   // y coordinate
Parameters
__beginbegin of data
__endend of data
precisionprecision

Definition at line 226 of file JCircle2D.hh.

229 {
230 if (__begin != __end) {
231
232 __x = __begin->getX();
233 __y = __begin->getY();
234 __r = 0.0;
235
236 T i = __begin;
237
238 const JVector2D p0(i->getX(), i->getY());
239
240 while (++i != __end && p0.getDistance(JVector2D(i->getX(), i->getY())) <= precision) {}
241
242 if (i != __end) {
243
244 const JVector2D p1(i->getX(), i->getY());
245
246 set(p0, p1);
247
248 while (++i != __end) {
249
250 const JVector2D p2(i->getX(), i->getY());
251
252 if (this->getDistance(p2) > this->getRadius() + precision &&
253 p0.getDistance(p2) > precision &&
254 p1.getDistance(p2) > precision) {
255 configure(__begin, i, p2, precision);
256 }
257 }
258 }
259 }
260 }
void configure(T __begin, T __end, const JVector2D &p0, const double precision)
Determine smallest enclosing circle.
Definition JCircle2D.hh:358

◆ is_inside() [2/2]

bool JGEOMETRY2D::JCircle2D::is_inside ( const JVector2D & pos,
const double precision = std::numeric_limits<double>::min() ) const
inlineinherited

Check whether given point is inside circle.

Parameters
posposition
precisionprecision
Returns
true if inside; else false

Definition at line 270 of file JCircle2D.hh.

272 {
273 return (this->getDistance(pos) <= this->getRadius() + precision);
274 }

◆ configure() [1/2]

template<class T >
void JGEOMETRY2D::JCircle2D::configure ( T __begin,
T __end,
const JVector2D & p0,
const double precision )
inlineprivateinherited

Determine smallest enclosing circle.

Parameters
__beginbegin of data
__endend of data
p0point on circle
precisionprecision

Definition at line 358 of file JCircle2D.hh.

362 {
363 this->set(JVector2D(__begin->getX(), __begin->getY()), p0);
364
365 for (T i = __begin; ++i != __end; ) {
366
367 const JVector2D p1(i->getX(), i->getY());
368
369 if (this->getDistance(p1) > this->getRadius() + precision &&
370 p0.getDistanceSquared(p1) > precision) {
371 configure(__begin, i, p0, p1, precision);
372 }
373 }
374 }

◆ configure() [2/2]

template<class T >
void JGEOMETRY2D::JCircle2D::configure ( T __begin,
T __end,
const JVector2D & p0,
const JVector2D & p1,
const double precision )
inlineprivateinherited

Determine smallest enclosing circle.

Parameters
__beginbegin of data
__endend of data
p0point on circle
p1point on circle
precisionprecision

Definition at line 387 of file JCircle2D.hh.

392 {
393 this->set(p0, p1);
394
395 for (T i = __begin; i != __end; ++i) {
396
397 const JVector2D p2(i->getX(), i->getY());
398
399 if (this->getDistance(p2) > this->getRadius() + precision &&
400 p0.getDistanceSquared(p2) > precision &&
401 p1.getDistanceSquared(p2) > precision) {
402 this->set(p0, p1, p2, precision);
403 }
404 }
405 }

◆ getPosition() [1/2]

const JPosition2D & JGEOMETRY2D::JPosition2D::getPosition ( ) const
inlineinherited

Get position.

Returns
position

Definition at line 98 of file JPosition2D.hh.

99 {
100 return static_cast<const JPosition2D&>(*this);
101 }

◆ getPosition() [2/2]

JPosition2D & JGEOMETRY2D::JPosition2D::getPosition ( )
inlineinherited

Get position.

Returns
position

Definition at line 109 of file JPosition2D.hh.

110 {
111 return static_cast<JPosition2D&>(*this);
112 }

◆ setPosition()

void JGEOMETRY2D::JPosition2D::setPosition ( const JVector2D & pos)
inlineinherited

Set position.

Parameters
posposition

Definition at line 120 of file JPosition2D.hh.

121 {
122 static_cast<JVector2D&>(*this) = pos;
123 }

◆ operator JAngle2D()

JGEOMETRY2D::JPosition2D::operator JAngle2D ( ) const
inlineinherited

Type conversion operator.

Returns
angle

Definition at line 131 of file JPosition2D.hh.

132 {
133 return JAngle2D(getX(), getY());
134 }

◆ operator JVersor2D()

JGEOMETRY2D::JPosition2D::operator JVersor2D ( ) const
inlineinherited

Type conversion operator.

Returns
direction

Definition at line 142 of file JPosition2D.hh.

143 {
144 return JVersor2D(getX(), getY());
145 }

◆ rotate()

JPosition2D & JGEOMETRY2D::JPosition2D::rotate ( const JRotation2D & R)
inlineinherited

Rotate.

Parameters
Rrotation matrix
Returns
this position

Definition at line 154 of file JPosition2D.hh.

155 {
156 R.rotate(__x, __y);
157
158 return *this;
159 }

◆ rotate_back()

JPosition2D & JGEOMETRY2D::JPosition2D::rotate_back ( const JRotation2D & R)
inlineinherited

Rotate back.

Parameters
Rrotation matrix
Returns
this position

Definition at line 168 of file JPosition2D.hh.

169 {
170 R.rotate_back(__x, __y);
171
172 return *this;
173 }

◆ getDot() [1/3]

double JGEOMETRY2D::JPosition2D::getDot ( const JAngle2D & angle) const
inlineinherited

Get dot product.

Parameters
angleangle
Returns
dot product

Definition at line 182 of file JPosition2D.hh.

183 {
184 return
185 getX() * angle.getDX() +
186 getY() * angle.getDY();
187 }

◆ getDot() [2/3]

double JGEOMETRY2D::JPosition2D::getDot ( const JVersor2D & versor) const
inlineinherited

Get dot product.

Parameters
versorversor
Returns
dot product

Definition at line 196 of file JPosition2D.hh.

197 {
198 return
199 getX() * versor.getDX() +
200 getY() * versor.getDY();
201 }

◆ getDot() [3/3]

double JGEOMETRY2D::JVector2D::getDot ( const JVector2D & point) const
inlineinherited

Get dot product.

Parameters
pointvector
Returns
dot product

Definition at line 235 of file JVector2D.hh.

236 {
237 return
238 getX() * point.getX() +
239 getY() * point.getY();
240 }

◆ getPerpDot() [1/3]

double JGEOMETRY2D::JPosition2D::getPerpDot ( const JAngle2D & angle) const
inlineinherited

Get perpendicular dot product.

Parameters
angleangle
Returns
perpendicular dot product

Definition at line 210 of file JPosition2D.hh.

211 {
212 return
213 getX() * angle.getDY() -
214 getY() * angle.getDX();
215 }

◆ getPerpDot() [2/3]

double JGEOMETRY2D::JPosition2D::getPerpDot ( const JVersor2D & dir) const
inlineinherited

Get perpendicular dot product.

Parameters
dirdirection
Returns
perpendicular dot product

Definition at line 224 of file JPosition2D.hh.

225 {
226 return
227 getX() * dir.getDY() -
228 getY() * dir.getDX();
229 }

◆ getPerpDot() [3/3]

double JGEOMETRY2D::JVector2D::getPerpDot ( const JVector2D & point) const
inlineinherited

Get perpendicular dot product.

Parameters
pointvector
Returns
perpendicular dot product

Definition at line 249 of file JVector2D.hh.

250 {
251 return
252 getX() * point.getY() -
253 getY() * point.getX();
254 }

◆ transform()

JVector2D & JGEOMETRY2D::JVector2D::transform ( const JMatrix2D & T)
inlineinherited

Transform.

Parameters
Tmatrix
Returns
this vector

Definition at line 160 of file JVector2D.hh.

161 {
162 T.transform(__x, __y);
163
164 return *this;
165 }

◆ getX()

double JGEOMETRY2D::JVector2D::getX ( ) const
inlineinherited

Get x position.

Returns
x position

Definition at line 63 of file JVector2D.hh.

64 {
65 return __x;
66 }

◆ getY()

double JGEOMETRY2D::JVector2D::getY ( ) const
inlineinherited

Get y position.

Returns
y position

Definition at line 74 of file JVector2D.hh.

75 {
76 return __y;
77 }

◆ negate()

JVector2D & JGEOMETRY2D::JVector2D::negate ( )
inlineinherited

Negate vector.

Returns
this vector

Definition at line 85 of file JVector2D.hh.

86 {
87 __x = -__x;
88 __y = -__y;
89
90 return *this;
91 }

◆ add() [2/2]

JVector2D & JGEOMETRY2D::JVector2D::add ( const JVector2D & vector)
inlineinherited

Add vector.

Parameters
vectorvector
Returns
this vector

Definition at line 100 of file JVector2D.hh.

101 {
102 __x += vector.getX();
103 __y += vector.getY();
104
105 return *this;
106 }

◆ sub()

JVector2D & JGEOMETRY2D::JVector2D::sub ( const JVector2D & vector)
inlineinherited

Subtract vector.

Parameters
vectorvector
Returns
this vector

Definition at line 115 of file JVector2D.hh.

116 {
117 __x -= vector.getX();
118 __y -= vector.getY();
119
120 return *this;
121 }

◆ mul() [1/2]

JVector2D & JGEOMETRY2D::JVector2D::mul ( const double factor)
inlineinherited

Scale vector.

Parameters
factormultiplication factor
Returns
this vector

Definition at line 130 of file JVector2D.hh.

131 {
132 __x *= factor;
133 __y *= factor;
134
135 return *this;
136 }

◆ mul() [2/2]

template<class JFirst_t , class JSecond_t >
JFirst_t & JMATH::JMath< JFirst_t, JSecond_t >::mul ( const JSecond_t & object)
inlineinherited

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 354 of file JMath.hh.

355 {
356 return static_cast<JFirst_t&>(*this) = JFirst_t().mul(static_cast<const JFirst_t&>(*this), object);
357 }

◆ div()

JVector2D & JGEOMETRY2D::JVector2D::div ( const double factor)
inlineinherited

Scale vector.

Parameters
factordivision factor
Returns
this vector

Definition at line 145 of file JVector2D.hh.

146 {
147 __x /= factor;
148 __y /= factor;
149
150 return *this;
151 }

◆ equals()

bool JGEOMETRY2D::JVector2D::equals ( const JVector2D & vector,
const double precision = std::numeric_limits<double>::min() ) const
inlineinherited

Check equality.

Parameters
vectorvector
precisionprecision
Returns
true if vectors are equal; else false

Definition at line 175 of file JVector2D.hh.

177 {
178 return (fabs(getX() - vector.getX()) <= precision &&
179 fabs(getY() - vector.getY()) <= precision);
180 }

◆ getLengthSquared()

double JGEOMETRY2D::JVector2D::getLengthSquared ( ) const
inlineinherited

Get length squared.

Returns
square of length

Definition at line 188 of file JVector2D.hh.

189 {
190 return getX()*getX() + getY()*getY();
191 }

◆ getLength()

double JGEOMETRY2D::JVector2D::getLength ( ) const
inlineinherited

Get length.

Returns
length

Definition at line 199 of file JVector2D.hh.

200 {
201 return sqrt(getLengthSquared());
202 }
double getLengthSquared() const
Get length squared.
Definition JVector2D.hh:188

◆ getDistanceSquared() [2/2]

double JGEOMETRY2D::JVector2D::getDistanceSquared ( const JVector2D & point) const
inlineinherited

Get squared of distance to point.

Parameters
pointpoint
Returns
square of distance

Definition at line 211 of file JVector2D.hh.

212 {
213 return JVector2D(point).sub(*this).getLengthSquared();
214 }

◆ getDistance() [2/2]

double JGEOMETRY2D::JVector2D::getDistance ( const JVector2D & point) const
inlineinherited

Get distance to point.

Parameters
pointpoint
Returns
distance

Definition at line 223 of file JVector2D.hh.

224 {
225 return sqrt(getDistanceSquared(point));
226 }
double getDistanceSquared(const JVector2D &point) const
Get squared of distance to point.
Definition JVector2D.hh:211

Friends And Related Symbol Documentation

◆ operator>> [1/2]

std::istream & operator>> ( std::istream & in,
JCylinder3D & cylinder )
friend

Read cylinder from input stream.

Parameters
ininput stream
cylindercylinder
Returns
input stream

Definition at line 347 of file JCylinder3D.hh.

348 {
349 in >> static_cast<JCircle2D&>(cylinder);
350 in >> cylinder.zmin >> cylinder.zmax;
351
352 return in;
353 }

◆ operator<< [1/2]

std::ostream & operator<< ( std::ostream & out,
const JCylinder3D & cylinder )
friend

Write cylinder to output stream.

Parameters
outoutput stream
cylindercylinder
Returns
output stream

Definition at line 363 of file JCylinder3D.hh.

364 {
365 const JFormat format(out, getFormat<JCylinder3D>(JFormat_t(9, 3, std::ios::fixed | std::ios::showpos)));
366
367 out << static_cast<const JCircle2D&>(cylinder);
368 out << ' ';
369 out << format << cylinder.zmin;
370 out << ' ';
371 out << format << cylinder.zmax;
372
373 return out;
374 }
JFormat_t & getFormat()
Get format for given type.
Definition JManip.hh:682
Data structure for format specifications.
Definition JManip.hh:524
Auxiliary class to temporarily define format specifications.
Definition JManip.hh:636

◆ operator>> [2/2]

JReader & operator>> ( JReader & in,
JCylinder3D & cylinder )
friend

Read cylinder from input.

Parameters
inreader
cylindercylinder
Returns
reader

Definition at line 384 of file JCylinder3D.hh.

385 {
386 in >> static_cast<JCircle2D&>(cylinder);
387 in >> cylinder.zmin >> cylinder.zmax;
388
389 return in;
390 }

◆ operator<< [2/2]

JWriter & operator<< ( JWriter & out,
const JCylinder3D & cylinder )
friend

Write cylinder to output.

Parameters
outwriter
cylindercylinder
Returns
writer

Definition at line 400 of file JCylinder3D.hh.

401 {
402 out << static_cast<const JCircle2D&>(cylinder);
403 out << cylinder.zmin << cylinder.zmax;
404
405 return out;
406 }

Member Data Documentation

◆ zmin

double JGEOMETRY3D::JCylinder3D::zmin
protected

Definition at line 410 of file JCylinder3D.hh.

◆ zmax

double JGEOMETRY3D::JCylinder3D::zmax
protected

Definition at line 411 of file JCylinder3D.hh.

◆ __r

double JGEOMETRY2D::JCircle2D::__r
protectedinherited

Definition at line 345 of file JCircle2D.hh.

◆ __x

double JGEOMETRY2D::JVector2D::__x
protectedinherited

Definition at line 257 of file JVector2D.hh.

◆ __y

double JGEOMETRY2D::JVector2D::__y
protectedinherited

Definition at line 258 of file JVector2D.hh.


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