Data structure for vector in three dimensions.
More...
#include <JVector3D.hh>
Data structure for vector in three dimensions.
This class implements the JMATH::JMath interface.
Definition at line 34 of file JVector3D.hh.
◆ JVector3D() [1/3]
JGEOMETRY3D::JVector3D::JVector3D |
( |
| ) |
|
|
inline |
◆ JVector3D() [2/3]
JGEOMETRY3D::JVector3D::JVector3D |
( |
const double | x, |
|
|
const double | y, |
|
|
const double | z ) |
|
inline |
Constructor.
- Parameters
-
x | x value |
y | y value |
z | z value |
Definition at line 55 of file JVector3D.hh.
◆ JVector3D() [3/3]
JGEOMETRY3D::JVector3D::JVector3D |
( |
const JVector2D & | vector, |
|
|
const double | z ) |
|
inline |
Constructor.
- Parameters
-
vector | (x,y) values |
z | z value |
Definition at line 70 of file JVector3D.hh.
◆ operator JVector2D()
JGEOMETRY3D::JVector3D::operator JVector2D |
( |
| ) |
const |
|
inline |
Type conversion operator.
- Returns
- JVector2D
Definition at line 83 of file JVector3D.hh.
84 {
85 return JVector2D(this->
getX(), this->
getY());
86 }
double getY() const
Get y position.
double getX() const
Get x position.
◆ getX()
double JGEOMETRY3D::JVector3D::getX |
( |
| ) |
const |
|
inline |
Get x position.
- Returns
- x position
Definition at line 94 of file JVector3D.hh.
◆ getY()
double JGEOMETRY3D::JVector3D::getY |
( |
| ) |
const |
|
inline |
Get y position.
- Returns
- y position
Definition at line 104 of file JVector3D.hh.
◆ getZ()
double JGEOMETRY3D::JVector3D::getZ |
( |
| ) |
const |
|
inline |
Get z position.
- Returns
- z position
Definition at line 115 of file JVector3D.hh.
◆ negate()
JVector3D & JGEOMETRY3D::JVector3D::negate |
( |
| ) |
|
|
inline |
Negate vector.
- Returns
- this vector
Definition at line 126 of file JVector3D.hh.
127 {
131
132 return *this;
133 }
◆ add()
Add vector.
- Parameters
-
- Returns
- this vector
Definition at line 142 of file JVector3D.hh.
143 {
144 __x += vector.getX();
145 __y += vector.getY();
146 __z += vector.getZ();
147
148 return *this;
149 }
◆ sub()
Subtract vector.
- Parameters
-
- Returns
- this vector
Definition at line 158 of file JVector3D.hh.
159 {
160 __x -= vector.getX();
161 __y -= vector.getY();
162 __z -= vector.getZ();
163
164 return *this;
165 }
◆ mul() [1/2]
JVector3D & JGEOMETRY3D::JVector3D::mul |
( |
const double | factor | ) |
|
|
inline |
Scale vector.
- Parameters
-
factor | multiplication factor |
- Returns
- this vector
Definition at line 174 of file JVector3D.hh.
175 {
179
180 return *this;
181 }
◆ div()
JVector3D & JGEOMETRY3D::JVector3D::div |
( |
const double | factor | ) |
|
|
inline |
Scale vector.
- Parameters
-
- Returns
- this vector
Definition at line 190 of file JVector3D.hh.
191 {
195
196 return *this;
197 }
◆ transform()
Transform.
- Parameters
-
- Returns
- this vector
Definition at line 206 of file JVector3D.hh.
207 {
209
210 return *this;
211 }
◆ equals()
bool JGEOMETRY3D::JVector3D::equals |
( |
const JVector3D & | vector, |
|
|
const double | precision = std::numeric_limits<double>::min() ) const |
|
inline |
Check equality.
- Parameters
-
vector | vector |
precision | precision |
- Returns
- true if vectors are equal; else false
Definition at line 221 of file JVector3D.hh.
223 {
224 return (fabs(
getX() - vector.getX()) <= precision &&
225 fabs(
getY() - vector.getY()) <= precision &&
226 fabs(
getZ() - vector.getZ()) <= precision);
227 }
double getZ() const
Get z position.
◆ getLengthSquared()
double JGEOMETRY3D::JVector3D::getLengthSquared |
( |
| ) |
const |
|
inline |
Get length squared.
- Returns
- square of length
Definition at line 235 of file JVector3D.hh.
◆ getLength()
double JGEOMETRY3D::JVector3D::getLength |
( |
| ) |
const |
|
inline |
Get length.
- Returns
- length
Definition at line 246 of file JVector3D.hh.
247 {
249 }
double getLengthSquared() const
Get length squared.
◆ getDistanceSquared()
double JGEOMETRY3D::JVector3D::getDistanceSquared |
( |
const JVector3D & | pos | ) |
const |
|
inline |
Get squared of distance to point.
- Parameters
-
- Returns
- square of distance
Definition at line 258 of file JVector3D.hh.
259 {
260 return JVector3D(pos).sub(*this).getLengthSquared();
261 }
JVector3D()
Default constructor.
◆ getDistance()
double JGEOMETRY3D::JVector3D::getDistance |
( |
const JVector3D & | pos | ) |
const |
|
inline |
Get distance to point.
- Parameters
-
- Returns
- distance
Definition at line 270 of file JVector3D.hh.
271 {
273 }
double getDistanceSquared(const JVector3D &pos) const
Get squared of distance to point.
◆ getDot()
double JGEOMETRY3D::JVector3D::getDot |
( |
const JVector3D & | vector | ) |
const |
|
inline |
Get dot product.
- Parameters
-
- Returns
- dot product
Definition at line 282 of file JVector3D.hh.
283 {
284 return
285 getX() * vector.getX() +
286 getY() * vector.getY() +
287 getZ() * vector.getZ();
288 }
◆ getCross()
Get cross product.
Note that this vector should not overlap with the first or second vector,
- Parameters
-
first | first vector |
second | second vector |
- Returns
- this vector
Definition at line 299 of file JVector3D.hh.
301 {
302 __x = first .getY() * second.getZ() - second.getY() * first .getZ();
303 __y = second.getX() * first .getZ() - first .getX() * second.getZ();
304 __z = first .getX() * second.getY() - second.getX() * first .getY();
305
306 return *this;
307 }
◆ 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
-
- 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 }
◆ __x
double JGEOMETRY3D::JVector3D::__x |
|
protected |
◆ __y
double JGEOMETRY3D::JVector3D::__y |
|
protected |
◆ __z
double JGEOMETRY3D::JVector3D::__z |
|
protected |
The documentation for this class was generated from the following file: