EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
Public Member Functions | List of all members
EGS_2DPolygon Class Reference

A class to represent a polygon in a plane (a 2D polygon). More...

#include <egs_polygon.h>

Public Member Functions

 EGS_2DPolygon (vector< EGS_2DVector > &points, bool Open=false)
 Construct a polygon from the 2D points points. More...
 
 ~EGS_2DPolygon ()
 Destructor.
 
int getN () const
 Get the number of points (vertices) in this polygon object.
 
bool isConvex () const
 Is the polygon convex ?
 
EGS_2DVector getNormal (int j) const
 Get a line normal to the j'th polygon edge.
 
EGS_Float hownear (bool in, const EGS_2DVector &x) const
 Get the nearest distance from x to the polygon. More...
 
bool isInside (const EGS_2DVector &x) const
 Is the 2D point x inside the polygon ?
 
bool howfar (bool in, const EGS_2DVector &x, const EGS_2DVector &u, EGS_Float &t, EGS_2DVector *normal=0)
 Will the line defined by position x and direction u intersect the polygon ? More...
 
EGS_2DVector getPoint (int j) const
 Get the j'th point of this polygon.
 

Detailed Description

A class to represent a polygon in a plane (a 2D polygon).

The EGS_2DPolygon class represents a polygon in a plane. It provides various functions which are useful for the implementation of the required geometry methods of prisms and pyramids.

Definition at line 59 of file egs_polygon.h.

Constructor & Destructor Documentation

EGS_2DPolygon::EGS_2DPolygon ( vector< EGS_2DVector > &  points,
bool  Open = false 
)

Construct a polygon from the 2D points points.

The optional Open argument has only a meaning for polygons with 3 points (triangles) and makes the triangle to be 'open', i.e. extend to infinity between the lines defined by the first and second point and the first and third point.

Definition at line 67 of file egs_polygon.cpp.

References egsFatal, epsilon, loopMax, and veryFar.

Member Function Documentation

EGS_Float EGS_2DPolygon::hownear ( bool  in,
const EGS_2DVector x 
) const

Get the nearest distance from x to the polygon.

The argument in must be true, if the 2D position x is inside the polygon, false otherwise.

Definition at line 100 of file egs_polygon.h.

References veryFar.

bool EGS_2DPolygon::howfar ( bool  in,
const EGS_2DVector x,
const EGS_2DVector u,
EGS_Float &  t,
EGS_2DVector normal = 0 
)

Will the line defined by position x and direction u intersect the polygon ?

This function returns true, if the line defined by position x and direction u intersects the polygon and false otherwise. If an intersection exists, t is set to the distance between x and the intersection point. In addition, if normal is not null, it is set to the normal to the edge being intersected. The argument in must be set to true, if x is inside the ploygon and to false otherwise.

Definition at line 189 of file egs_polygon.h.

References epsilon.


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