Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | List of all members
JGEOMETRY2D::JVector2D Class Reference

Data structure for vector in two dimensions. More...

#include <JVector2D.hh>

Inheritance diagram for JGEOMETRY2D::JVector2D:
JMATH::JMath< JVector2D > JGEOMETRY2D::JCenter2D JGEOMETRY2D::JEigenValues2D JGEOMETRY2D::JPosition2D JDETECTOR::JAnchor JGEOMETRY2D::JAxis2D JGEOMETRY2D::JCircle2D JGEOMETRY3D::JCylinder3D

Public Member Functions

 JVector2D ()
 Default constructor. More...
 
 JVector2D (const double x, const double y)
 Constructor. More...
 
double getX () const
 Get x position. More...
 
double getY () const
 Get y position. More...
 
JVector2Dnegate ()
 Negate vector. More...
 
JVector2Dadd (const JVector2D &vector)
 Add vector. More...
 
JVector2Dsub (const JVector2D &vector)
 Subtract vector. More...
 
JVector2Dmul (const double factor)
 Scale vector. More...
 
JVector2Ddiv (const double factor)
 Scale vector. More...
 
JVector2Dtransform (const JMatrix2D &T)
 Transform. More...
 
bool equals (const JVector2D &vector) const
 Check equality. More...
 
double getLengthSquared () const
 Get length squared. More...
 
double getLength () const
 Get length. More...
 
double getDistanceSquared (const JVector2D &point) const
 Get squared of distance to point. More...
 
double getDistance (const JVector2D &point) const
 Get distance to point. More...
 
double getDot (const JVector2D &point) const
 Get dot product. More...
 
double getPerpDot (const JVector2D &point) const
 Get perpendicular dot product. More...
 
JVector2Dmul (const JNullType &object)
 Multiply with object. More...
 

Protected Attributes

double __x
 
double __y
 

Detailed Description

Data structure for vector in two dimensions.

This class implements the JMATH::JMath interface.

Definition at line 30 of file JVector2D.hh.

Constructor & Destructor Documentation

JGEOMETRY2D::JVector2D::JVector2D ( )
inline

Default constructor.

Definition at line 37 of file JVector2D.hh.

37  :
38  __x(0.0),
39  __y(0.0)
40  {}
JGEOMETRY2D::JVector2D::JVector2D ( const double  x,
const double  y 
)
inline

Constructor.

Parameters
xx value
yy value

Definition at line 49 of file JVector2D.hh.

50  :
51  __x(x),
52  __y(y)
53  {}

Member Function Documentation

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

Get x position.

Returns
x position

Definition at line 61 of file JVector2D.hh.

62  {
63  return __x;
64  }
double JGEOMETRY2D::JVector2D::getY ( ) const
inline

Get y position.

Returns
y position

Definition at line 72 of file JVector2D.hh.

73  {
74  return __y;
75  }
JVector2D& JGEOMETRY2D::JVector2D::negate ( )
inline

Negate vector.

Returns
this vector

Definition at line 83 of file JVector2D.hh.

84  {
85  __x = -__x;
86  __y = -__y;
87 
88  return *this;
89  }
JVector2D& JGEOMETRY2D::JVector2D::add ( const JVector2D vector)
inline

Add vector.

Parameters
vectorvector
Returns
this vector

Definition at line 98 of file JVector2D.hh.

99  {
100  __x += vector.getX();
101  __y += vector.getY();
102 
103  return *this;
104  }
double getY() const
Get y position.
Definition: JVector2D.hh:72
double getX() const
Get x position.
Definition: JVector2D.hh:61
JVector2D& JGEOMETRY2D::JVector2D::sub ( const JVector2D vector)
inline

Subtract vector.

Parameters
vectorvector
Returns
this vector

Definition at line 113 of file JVector2D.hh.

114  {
115  __x -= vector.getX();
116  __y -= vector.getY();
117 
118  return *this;
119  }
double getY() const
Get y position.
Definition: JVector2D.hh:72
double getX() const
Get x position.
Definition: JVector2D.hh:61
JVector2D& JGEOMETRY2D::JVector2D::mul ( const double  factor)
inline

Scale vector.

Parameters
factormultiplication factor
Returns
this vector

Definition at line 128 of file JVector2D.hh.

129  {
130  __x *= factor;
131  __y *= factor;
132 
133  return *this;
134  }
JVector2D& JGEOMETRY2D::JVector2D::div ( const double  factor)
inline

Scale vector.

Parameters
factordivision factor
Returns
this vector

Definition at line 143 of file JVector2D.hh.

144  {
145  __x /= factor;
146  __y /= factor;
147 
148  return *this;
149  }
JVector2D& JGEOMETRY2D::JVector2D::transform ( const JMatrix2D T)
inline

Transform.

Parameters
Tmatrix
Returns
this vector

Definition at line 158 of file JVector2D.hh.

159  {
160  T.transform(__x, __y);
161 
162  return *this;
163  }
bool JGEOMETRY2D::JVector2D::equals ( const JVector2D vector) const
inline

Check equality.

Parameters
vectorvector
Returns
true if vectors are equal; else false

Definition at line 172 of file JVector2D.hh.

173  {
174  return (getX() == vector.getX() &&
175  getY() == vector.getY());
176  }
double getY() const
Get y position.
Definition: JVector2D.hh:72
double getX() const
Get x position.
Definition: JVector2D.hh:61
double JGEOMETRY2D::JVector2D::getLengthSquared ( ) const
inline

Get length squared.

Returns
square of length

Definition at line 184 of file JVector2D.hh.

185  {
186  return getX()*getX() + getY()*getY();
187  }
double getY() const
Get y position.
Definition: JVector2D.hh:72
double getX() const
Get x position.
Definition: JVector2D.hh:61
double JGEOMETRY2D::JVector2D::getLength ( ) const
inline

Get length.

Returns
length

Definition at line 195 of file JVector2D.hh.

196  {
197  return sqrt(getLengthSquared());
198  }
double getLengthSquared() const
Get length squared.
Definition: JVector2D.hh:184
double JGEOMETRY2D::JVector2D::getDistanceSquared ( const JVector2D point) const
inline

Get squared of distance to point.

Parameters
pointpoint
Returns
square of distance

Definition at line 207 of file JVector2D.hh.

208  {
209  return JVector2D(point).sub(*this).getLengthSquared();
210  }
JVector2D()
Default constructor.
Definition: JVector2D.hh:37
double JGEOMETRY2D::JVector2D::getDistance ( const JVector2D point) const
inline

Get distance to point.

Parameters
pointpoint
Returns
distance

Definition at line 219 of file JVector2D.hh.

220  {
221  return sqrt(getDistanceSquared(point));
222  }
double getDistanceSquared(const JVector2D &point) const
Get squared of distance to point.
Definition: JVector2D.hh:207
double JGEOMETRY2D::JVector2D::getDot ( const JVector2D point) const
inline

Get dot product.

Parameters
pointvector
Returns
dot product

Definition at line 231 of file JVector2D.hh.

232  {
233  return
234  getX() * point.getX() +
235  getY() * point.getY();
236  }
double getY() const
Get y position.
Definition: JVector2D.hh:72
double getX() const
Get x position.
Definition: JVector2D.hh:61
double JGEOMETRY2D::JVector2D::getPerpDot ( const JVector2D point) const
inline

Get perpendicular dot product.

Parameters
pointvector
Returns
perpendicular dot product

Definition at line 245 of file JVector2D.hh.

246  {
247  return
248  getX() * point.getY() -
249  getY() * point.getX();
250  }
double getY() const
Get y position.
Definition: JVector2D.hh:72
double getX() const
Get x position.
Definition: JVector2D.hh:61
JVector2D & JMATH::JMath< JVector2D , JNullType >::mul ( const JNullType object)
inlineinherited

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 273 of file JMath.hh.

274  {
275  return static_cast<JFirst_t&>(*this) = JCalculator<JFirst_t>::calculator.mul(static_cast<const JFirst_t&>(*this), object);
276  }
Auxiliary class for product evaluation of objects.
Definition: JCalculator.hh:18

Member Data Documentation

double JGEOMETRY2D::JVector2D::__x
protected

Definition at line 253 of file JVector2D.hh.

double JGEOMETRY2D::JVector2D::__y
protected

Definition at line 254 of file JVector2D.hh.


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