Panda3D
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
LVecBase2d Class Reference

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

Inheritance diagram for LVecBase2d:
LPoint2d LVector2d

Public Types

enum  { num_components = 2, is_int = 0 }
 

Public Member Functions

object __getattr__ (str attr_name)
 
 __init__ ()
 
 __init__ (const LVecBase2d)
 
 __init__ (double fill_value)
 
 __init__ (double x, double y)
 
object __ipow__ (double exponent)
 
LVecBase2d __pow__ (double exponent)
 
object __reduce__ ()
 
str __repr__ ()
 
int __setattr__ (str attr_name, object assign)
 
int addHash (int hash)
 Adds the vector into the running hash. More...
 
int addHash (int hash, double threshold)
 Adds the vector into the running hash. More...
 
 addToCell (int i, double value)
 
 addX (double value)
 
 addY (double value)
 
bool almostEqual (const LVecBase2d other)
 Returns true if two vectors are memberwise equal within a default tolerance based on the numeric type. More...
 
bool almostEqual (const LVecBase2d other, double threshold)
 Returns true if two vectors are memberwise equal within a specified tolerance. More...
 
int compareTo (const LVecBase2d other)
 This flavor of compare_to uses a default threshold value based on the numeric type. More...
 
int compareTo (const LVecBase2d other, double threshold)
 Sorts vectors lexicographically, componentwise. More...
 
 componentwiseMult (const LVecBase2d other)
 
double dot (const LVecBase2d other)
 
 fill (double fill_value)
 Sets each element of the vector to the indicated fill_value. More...
 
LVecBase2d fmax (const LVecBase2d other)
 
LVecBase2d fmin (const LVecBase2d other)
 
 generateHash (ChecksumHashGenerator hashgen)
 Adds the vector to the indicated hash generator. More...
 
 generateHash (ChecksumHashGenerator hashgen, double threshold)
 Adds the vector to the indicated hash generator. More...
 
double getCell (int i)
 
 getData ()
 Returns the address of the first of the two data elements in the vector. More...
 
int getHash ()
 Returns a suitable hash for phash_map. More...
 
int getHash (double threshold)
 Returns a suitable hash for phash_map. More...
 
double getX ()
 
double getY ()
 
bool isNan ()
 Returns true if any component of the vector is not-a-number, false otherwise. More...
 
double length ()
 Returns the length of the vector, by the Pythagorean theorem. More...
 
double lengthSquared ()
 Returns the square of the vector's length, cheap and easy. More...
 
bool normalize ()
 Normalizes the vector in place. More...
 
LVecBase2d normalized ()
 Normalizes the vector and returns the normalized vector as a copy. More...
 
bool operator != (const LVecBase2d other)
 
LVecBase2d operator * (double scalar)
 
LVecBase2d operator *= (double scalar)
 
LVecBase2d operator - ()
 
LVecBase2d operator - (const LVecBase2d other)
 
LVecBase2d operator -= (const LVecBase2d other)
 
 operator [] (int i, double assign_val)
 
double operator [] (int i)
 
 operator new (int size)
 
LVecBase2d operator+ (const LVecBase2d other)
 
LVecBase2d operator+= (const LVecBase2d other)
 
LVecBase2d operator/ (double scalar)
 
LVecBase2d operator/= (double scalar)
 
bool operator< (const LVecBase2d other)
 
LVecBase2d operator= (const LVecBase2d copy)
 
LVecBase2d operator= (double fill_value)
 
bool operator== (const LVecBase2d other)
 
 output (Ostream out)
 
LVecBase2d project (const LVecBase2d onto)
 Returns a new vector representing the projection of this vector onto another one. More...
 
 readDatagram (DatagramIterator source)
 Reads the vector from the Datagram using get_stdfloat(). More...
 
 readDatagramFixed (DatagramIterator source)
 Reads the vector from the Datagram using get_float32() or get_float64(). More...
 
 set (double x, double y)
 
 setCell (int i, double value)
 
 setX (double value)
 
 setY (double value)
 
 writeDatagram (Datagram destination)
 Writes the vector to the Datagram using add_stdfloat(). More...
 
 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(). More...
 

Static Public Member Functions

static TypeHandle getClassType ()
 
static int getNumComponents ()
 
static int size ()
 
static const LVecBase2d unitX ()
 Returns a unit X vector. More...
 
static const LVecBase2d unitY ()
 Returns a unit Y vector. More...
 
static const LVecBase2d zero ()
 Returns a zero-length vector. More...
 

Public Attributes

double x
 
double y
 

Detailed Description

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

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
num_components 
is_int 

Member Function Documentation

◆ __getattr__()

object __getattr__ ( str  attr_name)

◆ __init__() [1/4]

__init__ ( )

◆ __init__() [2/4]

__init__ ( const  LVecBase2d)

◆ __init__() [3/4]

__init__ ( double  fill_value)

◆ __init__() [4/4]

__init__ ( double  x,
double  y 
)

◆ __ipow__()

object __ipow__ ( double  exponent)

◆ __pow__()

LVecBase2d __pow__ ( double  exponent)

◆ __reduce__()

object __reduce__ ( )

◆ __repr__()

str __repr__ ( )

◆ __setattr__()

int __setattr__ ( str  attr_name,
object  assign 
)

◆ addHash() [1/2]

int addHash ( int  hash)

Adds the vector into the running hash.

◆ addHash() [2/2]

int addHash ( int  hash,
double  threshold 
)

Adds the vector into the running hash.

◆ addToCell()

addToCell ( int  i,
double  value 
)

◆ addX()

addX ( double  value)

◆ addY()

addY ( double  value)

◆ almostEqual() [1/2]

bool almostEqual ( const LVecBase2d  other)

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

◆ almostEqual() [2/2]

bool almostEqual ( const LVecBase2d  other,
double  threshold 
)

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

◆ compareTo() [1/2]

int compareTo ( const LVecBase2d  other)

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

◆ compareTo() [2/2]

int compareTo ( const LVecBase2d  other,
double  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).

◆ componentwiseMult()

componentwiseMult ( const LVecBase2d  other)

◆ dot()

double dot ( const LVecBase2d  other)

◆ fill()

fill ( double  fill_value)

Sets each element of the vector to the indicated fill_value.

This is particularly useful for initializing to zero.

◆ fmax()

LVecBase2d fmax ( const LVecBase2d  other)

◆ fmin()

LVecBase2d fmin ( const LVecBase2d  other)

◆ generateHash() [1/2]

generateHash ( ChecksumHashGenerator  hashgen)

Adds the vector to the indicated hash generator.

◆ generateHash() [2/2]

generateHash ( ChecksumHashGenerator  hashgen,
double  threshold 
)

Adds the vector to the indicated hash generator.

◆ getCell()

double getCell ( int  i)

◆ getClassType()

static TypeHandle getClassType ( )
static

◆ getData()

getData ( )

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

The next element occupies the next position consecutively in memory.

◆ getHash() [1/2]

int getHash ( )

Returns a suitable hash for phash_map.

◆ getHash() [2/2]

int getHash ( double  threshold)

Returns a suitable hash for phash_map.

◆ getNumComponents()

static int getNumComponents ( )
static

◆ getX()

double getX ( )

◆ getY()

double getY ( )

◆ isNan()

bool isNan ( )

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

◆ length()

double length ( )

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

◆ lengthSquared()

double lengthSquared ( )

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

◆ normalize()

bool normalize ( )

Normalizes the vector in place.

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

◆ normalized()

LVecBase2d normalized ( )

Normalizes the vector and returns the normalized vector as a copy.

If the vector was a zero-length vector, a zero length vector will be returned.

◆ operator !=()

bool operator != ( const LVecBase2d  other)

◆ operator *()

LVecBase2d operator * ( double  scalar)

◆ operator *=()

LVecBase2d operator *= ( double  scalar)

◆ operator -() [1/2]

LVecBase2d operator - ( )

◆ operator -() [2/2]

LVecBase2d operator - ( const LVecBase2d  other)

◆ operator -=()

LVecBase2d operator -= ( const LVecBase2d  other)

◆ operator []() [1/2]

operator [] ( int  i,
double  assign_val 
)

◆ operator []() [2/2]

double operator [] ( int  i)

◆ operator new()

operator new ( int  size)

◆ operator+()

LVecBase2d operator+ ( const LVecBase2d  other)

◆ operator+=()

LVecBase2d operator+= ( const LVecBase2d  other)

◆ operator/()

LVecBase2d operator/ ( double  scalar)

◆ operator/=()

LVecBase2d operator/= ( double  scalar)

◆ operator<()

bool operator< ( const LVecBase2d  other)

◆ operator=() [1/2]

LVecBase2d operator= ( const LVecBase2d  copy)

◆ operator=() [2/2]

LVecBase2d operator= ( double  fill_value)

◆ operator==()

bool operator== ( const LVecBase2d  other)

◆ output()

output ( Ostream  out)

◆ project()

LVecBase2d project ( const LVecBase2d  onto)

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

The resulting vector will be a scalar multiple of onto.

◆ readDatagram()

readDatagram ( DatagramIterator  source)

Reads the vector from the Datagram using get_stdfloat().

◆ readDatagramFixed()

readDatagramFixed ( DatagramIterator  source)

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

See write_datagram_fixed().

◆ set()

set ( double  x,
double  y 
)

◆ setCell()

setCell ( int  i,
double  value 
)

◆ setX()

setX ( double  value)

◆ setY()

setY ( double  value)

◆ size()

static int size ( )
static

◆ unitX()

static const LVecBase2d unitX ( )
static

Returns a unit X vector.

◆ unitY()

static const LVecBase2d unitY ( )
static

Returns a unit Y vector.

◆ writeDatagram()

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()

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.

◆ zero()

static const LVecBase2d zero ( )
static

Returns a zero-length vector.

Member Data Documentation

◆ x

double x

◆ y

double y