Panda3D

- Main Page
- Packages
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions

# VBase3 Class Reference

This is the base class for all three-component vectors and points. More...

Inheritance diagram for VBase3:

List of all members.

## Public Member Functions
| VBase3 ()
| VBase3 (VBase3 const copy)
| VBase3 (float x, float y, float z)
| VBase3 (float fill_value)
unsigned int | addHash (unsigned int hash)
| Adds the vector into the running hash.
unsigned int | addHash (unsigned int hash, float threshold)
| Adds the vector into the running hash.
| addToCell (int i, float value)
| addX (float value)
| addY (float value)
| addZ (float value)
bool | almostEqual (VBase3 const other)
| Returns true if two vectors are memberwise equal within a default tolerance based on the numeric type.
bool | almostEqual (VBase3 const other, float threshold)
| Returns true if two vectors are memberwise equal within a specified tolerance.
int | compareTo (VBase3 const other)
| This flavor of compare_to uses a default threshold value based on the numeric type.
int | compareTo (VBase3 const other, float threshold)
| Sorts vectors lexicographically, componentwise.
VBase3 | cross (VBase3 const other)
| crossInto (VBase3 const other)
float | dot (VBase3 const other)
| fill (float fill_value)
| Sets each element of the vector to the indicated fill_value.
VBase3 | fmax (VBase3 const other)
VBase3 | fmin (VBase3 const other)
| generateHash (ChecksumHashGenerator hashgen)
| Adds the vector to the indicated hash generator.
| generateHash (ChecksumHashGenerator hashgen, float threshold)
| Adds the vector to the indicated hash generator.
PyObject | getattr (string attr_name)
float | getCell (int i)
| getData ()
| Returns the address of the first of the three data elements in the vector.
unsigned int | getHash ()
| Returns a suitable hash for phash_map.
unsigned int | getHash (float threshold)
| Returns a suitable hash for phash_map.
int | getNumComponents ()
| Returns the number of elements in the vector, three.
VBase3 | getStandardizedHpr ()
| Try to un-spin the hpr to a standard form.
float | getX ()
VBase2 | getXy ()
| Returns a 2-component vector that shares just the first two components of this vector.
VBase2 | getXz ()
| Returns a 2-component vector that shares just the first and last components of this vector.
float | getY ()
VBase2 | getYz ()
| Returns a 2-component vector that shares just the last two components of this vector.
float | getZ ()
bool | isNan ()
| Returns true if any component of the vector is not-a-number, false otherwise.
float | length ()
| Returns the length of the vector, by the Pythagorean theorem.
float | lengthSquared ()
| Returns the square of the vector's length, cheap and easy.
bool | normalize ()
| Normalizes the vector in place.
| operator new (unsigned int size)
bool | operator!= (VBase3 const other)
VBase3 | operator* (float scalar)
VBase3 | operator*= (float scalar)
VBase3 | operator+ (VBase3 const other)
VBase3 | operator+= (VBase3 const other)
VBase3 | operator- ()
VBase3 | operator- (VBase3 const other)
VBase3 | operator-= (VBase3 const other)
VBase3 | operator/ (float scalar)
VBase3 | operator/= (float scalar)
bool | operator< (VBase3 const other)
| This performs a lexicographical comparison.
VBase3 | operator= (float fill_value)
VBase3 | operator= (VBase3 const copy)
bool | operator== (VBase3 const other)
| operator[] (int i)
float | operator[] (int i)
| output (ostream out)
VBase3 | project (VBase3 const onto)
| Returns a new vector representing the projection of this vector onto another one.
| pythonRepr (ostream out, string class_name)
| readDatagram (DatagramIterator source)
| Reads the vector from the Datagram using get_stdfloat().
| readDatagramFixed (DatagramIterator source)
| Reads the vector from the Datagram using get_float32() or get_float64().
PyObject | reduce (PyObject self)
| set (float x, float y, float z)
int | setattr (PyObject self, string attr_name, PyObject assign)
| setCell (int i, float value)
| setitem (int i, float v)
| setX (float value)
| setY (float value)
| setZ (float value)
| writeDatagram (Datagram destination)
| Writes the vector to the Datagram using add_stdfloat().
| writeDatagramFixed (Datagram destination)
| Writes the vector to the Datagram using add_float32() or add_float64(), depending on the type of floats in the vector, regardless of the setting of Datagram.set_stdfloat_double().
## Static Public Member Functions
static TypeHandle | getClassType ()
static int | size ()
| Returns 3: the number of components of a LVecBase3.
static VBase3 const | unitX ()
| Returns a unit X vector.
static VBase3 const | unitY ()
| Returns a unit Y vector.
static VBase3 const | unitZ ()
| Returns a unit Z vector.
static VBase3 const | zero ()
| Returns a zero-length vector.

## Detailed Description

This is the base class for all three-component vectors and points.

## Constructor & Destructor Documentation

VBase3 | ( |  | ) |

VBase3 | ( | VBase3 const | copy | ) |

VBase3 | ( | float | fill_value | ) |

VBase3 | ( | float | x,
|  | float | y,
|  | float | z
| ) |  |

## Member Function Documentation

unsigned int addHash | ( | unsigned int | hash | ) |

Adds the vector into the running hash.

unsigned int addHash | ( | unsigned int | hash,
|  | float | threshold
| ) |  |

Adds the vector into the running hash.

addToCell | ( | int | i,
|  | float | value
| ) |  |

addX | ( | float | value | ) |

addY | ( | float | value | ) |

addZ | ( | float | value | ) |

bool almostEqual | ( | VBase3 const | other,
|  | float | threshold
| ) |  |

Returns true if two vectors are memberwise equal within a specified tolerance.

bool almostEqual | ( | VBase3 const | other | ) |

Returns true if two vectors are memberwise equal within a default tolerance based on the numeric type.

int compareTo | ( | VBase3 const | other | ) |

This flavor of compare_to uses a default threshold value based on the numeric type.

int compareTo | ( | VBase3 const | other,
|  | float | threshold
| ) |  |

Sorts vectors lexicographically, componentwise.

Returns a number less than 0 if this vector sorts before the other one, greater than zero if it sorts after, 0 if they are equivalent (within the indicated tolerance).

VBase3 cross | ( | VBase3 const | other | ) |

Reimplemented in Vec3, and Point3.

crossInto | ( | VBase3 const | other | ) |

float dot | ( | VBase3 const | other | ) |

fill | ( | float | fill_value | ) |

Sets each element of the vector to the indicated fill_value.

This is particularly useful for initializing to zero.

VBase3 fmax | ( | VBase3 const | other | ) |

VBase3 fmin | ( | VBase3 const | other | ) |

generateHash | ( | ChecksumHashGenerator | hashgen | ) |

Adds the vector to the indicated hash generator.

generateHash | ( | ChecksumHashGenerator | hashgen,
|  | float | threshold
| ) |  |

Adds the vector to the indicated hash generator.

PyObject getattr | ( | string | attr_name | ) |

Reimplemented in Vec3, and Point3.

float getCell | ( | int | i | ) |

static TypeHandle getClassType | ( |  | ) | `[static]`

Reimplemented in Vec3, and Point3.

getData | ( |  | ) |

Returns the address of the first of the three data elements in the vector.

The remaining elements occupy the next positions consecutively in memory.

unsigned int getHash | ( |  | ) |

Returns a suitable hash for phash_map.

unsigned int getHash | ( | float | threshold | ) |

Returns a suitable hash for phash_map.

int getNumComponents | ( |  | ) |

Returns the number of elements in the vector, three.

VBase3 getStandardizedHpr | ( |  | ) |

Try to un-spin the hpr to a standard form.

Like all standards, someone decides between many arbitrary possible standards. This function assumes that 0 and 360 are the same, as is 720 and -360. Also 180 and -180 are the same. Another example is -90 and 270. Each element will be in the range -180.0 to 179.99999. The original usage of this function is for human readable output.

It doesn't work so well for asserting that foo_hpr is roughly equal to bar_hpr. Try using LQuaternionf.is_same_direction() for that. See Also: get_standardized_rotation, LQuaternion.is_same_direction

float getX | ( |  | ) |

VBase2 getXy | ( |  | ) |

Returns a 2-component vector that shares just the first two components of this vector.

Reimplemented in Vec3, and Point3.

VBase2 getXz | ( |  | ) |

Returns a 2-component vector that shares just the first and last components of this vector.

Reimplemented in Vec3, and Point3.

float getY | ( |  | ) |

VBase2 getYz | ( |  | ) |

Returns a 2-component vector that shares just the last two components of this vector.

Reimplemented in Vec3, and Point3.

float getZ | ( |  | ) |

bool isNan | ( |  | ) |

Returns true if any component of the vector is not-a-number, false otherwise.

float length | ( |  | ) |

Returns the length of the vector, by the Pythagorean theorem.

float lengthSquared | ( |  | ) |

Returns the square of the vector's length, cheap and easy.

bool normalize | ( |  | ) |

Normalizes the vector in place.

Returns true if the vector was normalized, false if it was a zero-length vector.

operator new | ( | unsigned int | size | ) |

bool operator!= | ( | VBase3 const | other | ) |

VBase3 operator* | ( | float | scalar | ) |

Reimplemented in Vec3, and Point3.

VBase3 operator*= | ( | float | scalar | ) |

VBase3 operator+ | ( | VBase3 const | other | ) |

Reimplemented in Vec3, and Point3.

VBase3 operator+= | ( | VBase3 const | other | ) |

VBase3 operator- | ( | VBase3 const | other | ) |

Reimplemented in Vec3, and Point3.

VBase3 operator- | ( |  | ) |

Reimplemented in Vec3, and Point3.

VBase3 operator-= | ( | VBase3 const | other | ) |

VBase3 operator/ | ( | float | scalar | ) |

Reimplemented in Vec3, and Point3.

VBase3 operator/= | ( | float | scalar | ) |

bool operator< | ( | VBase3 const | other | ) |

This performs a lexicographical comparison.

It's of questionable mathematical meaning, but sometimes has a practical purpose for sorting unique vectors, especially in an STL container. Also see compare_to().

VBase3 operator= | ( | float | fill_value | ) |

Reimplemented in Vec3, and Point3.

VBase3 operator= | ( | VBase3 const | copy | ) |

Reimplemented in Vec3, and Point3.

bool operator== | ( | VBase3 const | other | ) |

operator[] | ( | int | i | ) |

float operator[] | ( | int | i | ) |

output | ( | ostream | out | ) |

VBase3 project | ( | VBase3 const | onto | ) |

Returns a new vector representing the projection of this vector onto another one.

The resulting vector will be a scalar multiple of onto.

Reimplemented in Vec3, and Point3.

pythonRepr | ( | ostream | out,
|  | string | class_name
| ) |  |

Reimplemented in Vec3, and Point3.

readDatagram | ( | DatagramIterator | source | ) |

Reads the vector from the Datagram using get_stdfloat().

readDatagramFixed | ( | DatagramIterator | source | ) |

Reads the vector from the Datagram using get_float32() or get_float64().

See write_datagram_fixed().

PyObject reduce | ( | PyObject | self | ) |

set | ( | float | x,
|  | float | y,
|  | float | z
| ) |  |

int setattr | ( | PyObject | self,
|  | string | attr_name,
|  | PyObject | assign
| ) |  |

Reimplemented in Vec3, and Point3.

setCell | ( | int | i,
|  | float | value
| ) |  |

setitem | ( | int | i,
|  | float | v
| ) |  |

setX | ( | float | value | ) |

setY | ( | float | value | ) |

setZ | ( | float | value | ) |

static int size | ( |  | ) | `[static]`

Returns 3: the number of components of a LVecBase3.

static VBase3 const unitX | ( |  | ) | `[static]`

Returns a unit X vector.

Reimplemented in Vec3, and Point3.

static VBase3 const unitY | ( |  | ) | `[static]`

Returns a unit Y vector.

Reimplemented in Vec3, and Point3.

static VBase3 const unitZ | ( |  | ) | `[static]`

Returns a unit Z vector.

Reimplemented in Vec3, and Point3.

writeDatagram | ( | Datagram | destination | ) |

Writes the vector to the Datagram using add_stdfloat().

This is appropriate when you want to write the vector using the standard width setting, especially when you are writing a bam file.

writeDatagramFixed | ( | Datagram | destination | ) |

Writes the vector to the Datagram using add_float32() or add_float64(), depending on the type of floats in the vector, regardless of the setting of Datagram.set_stdfloat_double().

This is appropriate when you want to write a fixed-width value to the datagram, especially when you are not writing a bam file.

static VBase3 const zero | ( |  | ) | `[static]`

Returns a zero-length vector.

Reimplemented in Vec3, and Point3.

All Classes Namespaces Functions Variables Enumerations Enumerator Properties