Jpp 21.0.0
the software that should make you happy
Loading...
Searching...
No Matches
JGEOMETRY2D::JEllipse2D_t Struct Reference

Ellipse. More...

#include <JEllipse2D.hh>

Public Member Functions

 JEllipse2D_t (const double A, const double B, const double C, const double D, const double E, const double F)
 Constructor.
 
 JEllipse2D_t (const JEllipse2D &ellipse)
 Constructor.
 
double operator() (const JVector2D &p) const
 Evaluate ellipse equation for given point.
 
bool is_inside (const JVector2D &p, const double precision=1.0e-8) const
 Check if a point is inside or on the boundary of the ellipse.
 
double getArea () const
 Get area.
 

Public Attributes

double A
 
double B
 
double C
 
double D
 
double E
 
double F
 

Friends

std::istream & operator>> (std::istream &in, JEllipse2D_t &ellipse)
 Read ellipse from input.
 
std::ostream & operator<< (std::ostream &out, const JEllipse2D_t &ellipse)
 Write ellipse to output.
 

Detailed Description

Ellipse.

\[
Ax^{2} + Bxy + Cy^{2} + Dx + Ey + F = 0
\]

Definition at line 316 of file JEllipse2D.hh.

Constructor & Destructor Documentation

◆ JEllipse2D_t() [1/2]

JGEOMETRY2D::JEllipse2D_t::JEllipse2D_t ( const double A,
const double B,
const double C,
const double D,
const double E,
const double F )
inline

Constructor.

Parameters
AA
BB
CC
DD
EE
FF

Definition at line 327 of file JEllipse2D.hh.

◆ JEllipse2D_t() [2/2]

JGEOMETRY2D::JEllipse2D_t::JEllipse2D_t ( const JEllipse2D & ellipse)
inline

Constructor.

Parameters
ellipseellipse

Definition at line 347 of file JEllipse2D.hh.

348 {
349 const double st = sin(ellipse.getAngle());
350 const double ct = cos(ellipse.getAngle());
351
352 const double x = ellipse.getX();
353 const double y = ellipse.getY();
354
355 const double a = ellipse.getMajorAxis();
356 const double b = ellipse.getMinorAxis();
357
358 A = a*a * st*st + b*b * ct*ct;
359 B = 2.0 * (b*b - a*a) * st*ct;
360 C = a*a * ct*ct + b*b * st*st;
361 D = -2.0*A*x - B*y;
362 E = -B*x - 2.0*C*y;
363 F = A*x*x + B*x*y + C*y*y - a*a * b*b;
364 }

Member Function Documentation

◆ operator()()

double JGEOMETRY2D::JEllipse2D_t::operator() ( const JVector2D & p) const
inline

Evaluate ellipse equation for given point.

Parameters
ppoint

Definition at line 372 of file JEllipse2D.hh.

373 {
374 return (A * p.getX() * p.getX() +
375 B * p.getX() * p.getY() +
376 C * p.getY() * p.getY() +
377 D * p.getX() +
378 E * p.getY() +
379 F);
380 }

◆ is_inside()

bool JGEOMETRY2D::JEllipse2D_t::is_inside ( const JVector2D & p,
const double precision = 1.0e-8 ) const
inline

Check if a point is inside or on the boundary of the ellipse.

Parameters
ppoint
precisionprecision

Definition at line 389 of file JEllipse2D.hh.

390 {
391 return (*this)(p) <= precision;
392 }

◆ getArea()

double JGEOMETRY2D::JEllipse2D_t::getArea ( ) const
inline

Get area.

Returns
area

Definition at line 400 of file JEllipse2D.hh.

401 {
402 using JMATH::PI;
403
404 const double U = 4*A*C - B*B;
405
406 return PI * 2.0 * (A*E*E + C*D*D - B*D*E - U*F) / (U * sqrt(U));
407 }
static const double PI
Mathematical constants.

Friends And Related Symbol Documentation

◆ operator>>

std::istream & operator>> ( std::istream & in,
JEllipse2D_t & ellipse )
friend

Read ellipse from input.

Parameters
ininput stream
ellipseellipse
Returns
input stream

Definition at line 417 of file JEllipse2D.hh.

418 {
419 return in >> ellipse.A >> ellipse.B >> ellipse.C >> ellipse.D >> ellipse.E >> ellipse.F;
420 }

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
const JEllipse2D_t & ellipse )
friend

Write ellipse to output.

Parameters
outoutput stream
ellipseellipse
Returns
output stream

Definition at line 430 of file JEllipse2D.hh.

431 {
432 const JFormat format(out, getFormat<JEllipse2D_t>(JFormat_t(9, 5, std::ios::fixed | std::ios::showpos)));
433
434 return out << format << ellipse.A << ' '
435 << format << ellipse.B << ' '
436 << format << ellipse.C << ' '
437 << format << ellipse.D << ' '
438 << format << ellipse.E << ' '
439 << format << ellipse.F;
440 }
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

Member Data Documentation

◆ A

double JGEOMETRY2D::JEllipse2D_t::A

Definition at line 443 of file JEllipse2D.hh.

◆ B

double JGEOMETRY2D::JEllipse2D_t::B

Definition at line 444 of file JEllipse2D.hh.

◆ C

double JGEOMETRY2D::JEllipse2D_t::C

Definition at line 445 of file JEllipse2D.hh.

◆ D

double JGEOMETRY2D::JEllipse2D_t::D

Definition at line 446 of file JEllipse2D.hh.

◆ E

double JGEOMETRY2D::JEllipse2D_t::E

Definition at line 447 of file JEllipse2D.hh.

◆ F

double JGEOMETRY2D::JEllipse2D_t::F

Definition at line 448 of file JEllipse2D.hh.


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