12using namespace Triton;
 
   16#ifndef TRITON_VECTOR3_H 
   17#define TRITON_VECTOR3_H 
   19#if defined(__INTEL_COMPILER) 
   44    Vector3(
double px, 
double py, 
double pz) : 
x(px), y(py), z(pz) {
 
   48    Vector3(
const double *p) : 
x(p[0]), y(p[1]), z(p[2]) {
 
   57        return sqrt(
x*
x + y*y + z*z);
 
   63        return (
x*
x + y*y + z*z);
 
   79        return x * v.
x + y * v.y + z * v.z;
 
   87        kCross.
x = y*v.z - z*v.y;
 
   88        kCross.y = z*v.
x - 
x*v.z;
 
   89        kCross.z = 
x*v.y - y*v.
x;
 
  111        return Vector3(
x - v.
x, y - v.y, z- v.z);
 
  116        return Vector3(
x + v.
x, y + v.y, z + v.z);
 
  121        return (v.
x == 
x && v.y ==y && v.z == z);
 
  126        return (v.
x != 
x || v.y != y || v.z != z);
 
  131        s.write((
char *)&
x, 
sizeof(
double));
 
  132        s.write((
char *)&y, 
sizeof(
double));
 
  133        s.write((
char *)&z, 
sizeof(
double));
 
  138        s.read((
char *)&
x, 
sizeof(
double));
 
  139        s.read((
char *)&y, 
sizeof(
double));
 
  140        s.read((
char *)&z, 
sizeof(
double));
 
  161    Vector3f(
float px, 
float py, 
float pz) : 
x(px), y(py), z(pz) {
 
  166        return (
float)sqrt(
x*
x + y*y + z*z);
 
  171        float n = 1.0f / 
Length();
 
  179        return x * v.
x + y * v.y + z * v.z;
 
  184        return Vector3(
x - v.
x, y - v.y, z- v.z);
 
  189        return Vector3(
x + v.
x, y + v.y, z + v.z);
 
  221        TBoundingBox(
double minX, 
double minY, 
double minZ, 
double maxX, 
double maxY, 
double maxZ)
 
  229                return ((v.
x >= m_vMin.x) && (v.y >= m_vMin.y) && (v.z >= m_vMin.z) && 
 
  230                        (v.
x <= m_vMax.x) && (v.y <= m_vMax.y) && (v.z <= m_vMax.z));
 
Memory allocation interface for SilverLining.
A 3D Vector class and its operations.
This base class for all Triton objects intercepts the new and delete operators, routing them through ...
Definition: MemAlloc.h:71
A 3D double-precision Vector class and its operations.
Definition: Vector3.h:36
void TRITONAPI Normalize()
Scales the vector to be of length 1.0.
Definition: Vector3.h:67
Vector3(const Vector3 &v)
Copy constructor.
Definition: Vector3.h:52
double TRITONAPI Length() const
Returns the length of the vector.
Definition: Vector3.h:56
bool TRITONAPI operator==(const Vector3 &v) const
Tests if two vectors are exactly equal.
Definition: Vector3.h:120
Vector3(double px, double py, double pz)
Constructs a Vector3 with the given x,y,z coordinates.
Definition: Vector3.h:44
void TRITONAPI Unserialize(std::istream &s)
Restore this vector from a file.
Definition: Vector3.h:137
double TRITONAPI SquaredLength() const
Returns the squared length of the vector, which is faster than computing the length.
Definition: Vector3.h:62
double x
Data members x,y,z public for convenience.
Definition: Vector3.h:144
Vector3 TRITONAPI operator-(const Vector3 &v) const
Subtracts the specified vector from this vector, and returns the result.
Definition: Vector3.h:110
Vector3()
Default constructor, initializes to (0,0,0).
Definition: Vector3.h:39
double TRITONAPI Dot(const Vector3 &v) const
Determines the dot product between this vector and another, and returns the result.
Definition: Vector3.h:78
Vector3 TRITONAPI Cross(const Vector3 &v) const
Determines the cross product between this vector and another, and returns the result.
Definition: Vector3.h:84
Vector3 TRITONAPI operator+(double n) const
Adds a constant n to each component of the vector, and returns the result.
Definition: Vector3.h:105
Vector3 TRITONAPI operator*(double n) const
Scales each x,y,z value of the vector by a constant n, and returns the result.
Definition: Vector3.h:95
bool TRITONAPI operator!=(const Vector3 &v) const
Test if two vectors are not exactly equal.
Definition: Vector3.h:125
void TRITONAPI Serialize(std::ostream &s) const
Write this vector's data to a file.
Definition: Vector3.h:130
Vector3(const double *p)
Constructs a Vector 3 from a pointer to 3 doubles.
Definition: Vector3.h:48
A 3D single-precision vector class, and its operations.
Definition: Vector3.h:149
Vector3f(float px, float py, float pz)
Constructs a Vector3f from the specified single-precision floating point x, y, and z values.
Definition: Vector3.h:161
Vector3f TRITONAPI operator*(const Vector3f &v) const
Multiplies the components of two vectors together, and returns the result.
Definition: Vector3.h:193
Vector3f TRITONAPI operator+(const Vector3f &v) const
Adds this vector to the specified vector, and returns the result.
Definition: Vector3.h:188
Vector3f(const Triton::Vector3 &v)
Construct a single precision vector from a double precision one.
Definition: Vector3.h:156
void TRITONAPI Normalize()
Scales the vector to be of length 1.0.
Definition: Vector3.h:170
Vector3f TRITONAPI operator-(const Vector3f &v) const
Subtracts the specified vector from this vector, and returns the result.
Definition: Vector3.h:183
float x
Data members x, y, z are public for convenience.
Definition: Vector3.h:203
float TRITONAPI Length()
Returns the length of this vector.
Definition: Vector3.h:165
Vector3f()
Default constructor; does not initialize the vector.
Definition: Vector3.h:152
double TRITONAPI Dot(const Vector3f &v) const
Returns the dot product of this vector with the specified Vector3.
Definition: Vector3.h:178