Vector Struct Reference

#include <Vector.h>

Description

3D and 2D positional vector.

A hybrid class suitable for both 2D and 3D positional and physical operations.

Functions

 Vector ()
 
 Vector (float x, float y, float z=0.f)
 
 Vector (const std::vector< float > &)
 
 Vector (const std::string &)
 
float Length () const
 
float Distance (const Vector &) const
 
Vector operator/ (const Vector &) const
 
Vector operator* (const Vector &) const
 
Vector operator+ (const Vector &) const
 
Vector operator- (const Vector &) const
 
Vector operator- () const
 
Vector Normalize () const
 
float Dot (const Vector &) const
 
float CrossFlat (const Vector &) const
 
Vector Cross (const Vector &) const
 
Vector Floor () const
 
VectorSetToNormalize ()
 
VectorSetToFloor ()
 
Arithmetic operations.

Vector supports the following arithmetic operations, For these, the input and operation are applied to x, y, and z.

Vector operator/ (float) const
 
Vector operator* (float) const
 
Vector operator+ (float) const
 
Vector operator- (float) const
 
Arithmetic setting operations.

These are equivalent to the Arithmetic operations, but *this is set to the result and returned.

Vectoroperator/= (const Vector &)
 
Vectoroperator*= (const Vector &)
 
Vectoroperator+= (const Vector &)
 
Vectoroperator-= (const Vector &)
 
Vectoroperator/= (float)
 
Vectoroperator*= (float)
 
Vectoroperator+= (float)
 
Vectoroperator-= (float)
 
X axis rotation

If a vector has length zero in these dimensions , the angle is always zero. The rotation is about the directional vector (1, 0, 0) and Positive rotation is towards the positive Z direction.

float RotationXDiff (const Vector &) const
 
float RotationXDiffRelative (const Vector &) const
 
float RotationX () const
 
Y axis rotation

If a vector has length zero in these dimensions , the angle is always zero. The rotation is about the directional vector (0, 1, 0) Positive rotation is towards the positive X direction.

float RotationYDiff (const Vector &) const
 
float RotationYDiffRelative (const Vector &) const
 
float RotationY () const
 
Z rotation axis

These deals with angles between the x and y axes. XY is most useful for 2D angles and transformations. If a vector has length zero in these dimensions , the angle is always zero. The rotation is about the directional vector (0, 0, 1). Positive rotation is towards the positive Y direction.

float RotationZDiff (const Vector &) const
 
float RotationZDiffRelative (const Vector &) const
 
float RotationZ () const
 
Vector RotateZ (float)
 
Partial setting

Sets x y and z to newly appointed values.

Vectoroperator() (float, float)
 
Vectoroperator() (float, float, float)
 
Vectoroperator() (const Vector &)
 

Properties

Positions
float x
 
float y
 
float z
 

Constructor & Destructor Documentation

Vector ( )

Initializes x, y, and z to 0.

Vector ( float  x,
float  y,
float  z = 0.f 
)

Defines all coordinates.

Vector ( const std::vector< float > &  )

Defines up to 3 coordinates. If fewer than 3 are given, the remaining components are left at 0.

Vector ( const std::string &  )

Attempts to retrieve coordinates from formatted text.

THe format of the text is 2 to 3 floating point numbers separated by any counts of either whitespace or generally accepted separation characters: ,.<>(){}[]

The point here is to allow instantiation from natural mathematical notations which depend on the usage of the Vector. Examples of valid input:

Vector("{1, 4, 5}"); Vector("1 4 5"); Vector("<1 4 5>"); Vector("[1 4 5]");

Member Function Documentation

float Length ( ) const

Returns the length of the vector.

This is equivalent to distance(Vector()).

float Distance ( const Vector ) const

Returns the distance of this vector to the other vector.

Vector operator/ ( const Vector ) const

Divides all corresponding members and returns the outcome.

Vector operator* ( const Vector ) const

Multiplies all corresponding members and returns the outcome.

Vector operator+ ( const Vector ) const

Adds all corresponding members and returns the outcome.

Vector operator- ( const Vector ) const

Subtracts all corresponding members and returns the outcome.

Vector operator- ( ) const

Negates all components.

Vector Normalize ( ) const

Returns a copy of the Vector with a magnitude of 1.

float Dot ( const Vector ) const

returns the dot product of the two vectors.

The dot product is defined as (a.length() * b.length() * cos()) where theta is the angle between the 2 vectors

float CrossFlat ( const Vector ) const

Returns the 2D cross product.

A cross product is computed as if the z components were equal to zero. This gives the magnitude, or Z of the cross product.

Vector Cross ( const Vector ) const

Returns the cross product.

float RotationXDiff ( const Vector ) const

returns the YZ angle between the 2 vectors in relation to the origin in degrees

float RotationXDiffRelative ( const Vector ) const

returns the angle between the 2 vectors in relation to (*this) in degrees

float RotationX ( ) const

returns the angle of the vector in degrees

float RotationYDiff ( const Vector ) const

Returns the zx angle between the 2 vectors in relation to the origin in degrees.

float RotationYDiffRelative ( const Vector ) const

returns the angle between the 2 vectors in relation to (*this) in degrees

float RotationY ( ) const

returns the angle of the vector in degrees.

float RotationZDiff ( const Vector ) const

returns the XY angle between the 2 vectors in relation to the origin in degrees

float RotationZDiffRelative ( const Vector ) const

returns the angle between the 2 vectors in relation to (*this) in degrees

float RotationZ ( ) const

returns the angle of the vector in degrees

Vector RotateZ ( float  )

Returns the result of rotating the vector by the specified degrees about the center.

Vector Floor ( ) const

Returns a version of the vector with the fractional values of each component dropped.

Vector& SetToNormalize ( )

Shorthand for (*this) = normalize().

Vector& SetToFloor ( )

Shorthand for (*this) = floor().


The documentation for this struct was generated from the following file:
  • /home/jc/git/Dynacoe/DynacoeSrc/includes/Dynacoe/Util/Vector.h