Roboid Control for Python
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
Spherical Class Reference

Detailed Description

A spherical 3D vector.

Inheritance diagram for Spherical:
Polar Polar

Public Member Functions

 __init__ (self, float distance, Direction direction)
 Create a new spherical vector.
 
 Degrees (float distance, float horizontal, float vertical)
 Create sperical vector without using the Direction type.
 
 Radians (float distance, float horizontal, float vertical)
 Create sperical vector without using the Direction type.
 
Vector3 ToVector3 (self)
 Convert the spherical coordinate to a Vector3 coordinate.
 
bool __eq__ (self, other)
 Check if this vector is equal to the given vector.
 
float Normalized (self)
 
 __neg__ (self)
 Negate the vector.
 
 __sub__ (self, other)
 Subtract a spherical vector from this vector.
 
 __add__ (self, other)
 Add a spherical vector to this vector.
 
 __mul__ (self, factor)
 Scale the vector uniformly up.
 
 __truediv__ (self, factor)
 Scale the vector uniformly down.
 
Angle SignedAngle (s1, s2, axis)
 Calculate the signed angle between two spherical vectors.
 
 __repr__ (self)
 
 __init__ (self, float distance, Direction direction)
 Create a new spherical vector.
 
 Degrees (float distance, float horizontal, float vertical)
 Create sperical vector without using the Direction type.
 
 Radians (float distance, float horizontal, float vertical)
 Create sperical vector without using the Direction type.
 
Vector3 ToVector3 (self)
 Convert the spherical coordinate to a Vector3 coordinate.
 
bool __eq__ (self, other)
 Check if this vector is equal to the given vector.
 
 isclose (self, other, rel_tol=1e-9, abs_tol=1e-8)
 
float Normalized (self)
 
 __neg__ (self)
 Negate the vector.
 
 __sub__ (self, other)
 Subtract a spherical vector from this vector.
 
 __add__ (self, other)
 Add a spherical vector to this vector.
 
 __mul__ (self, factor)
 Scale the vector uniformly up.
 
 __truediv__ (self, factor)
 Scale the vector uniformly down.
 
Angle SignedAngle (s1, s2, axis)
 Calculate the signed angle between two spherical vectors.
 
 __repr__ (self)
 

Static Public Member Functions

 FromVector3 (Vector3 v)
 Create a Spherical coordinate from a Vector3 coordinate.
 
float Distance (v1, v2)
 Calculate the distance between two spherical coordinates.
 
Angle Angle (s1, s2)
 Calculate the unsigned angle between two spherical vectors.
 
 Rotate (s, Angle horizontal, Angle vertical)
 Rotate a spherical vector.
 
 FromVector3 (Vector3 v)
 Create a Spherical coordinate from a Vector3 coordinate.
 
float Distance (v1, v2)
 Calculate the distance between two spherical coordinates.
 
Angle Angle (s1, s2)
 Calculate the unsigned angle between two spherical vectors.
 
 Rotate (s, Angle horizontal, Angle vertical)
 Rotate a spherical vector.
 

Public Attributes

 distance
 The direction of the vector.
 
 direction
 

Static Public Attributes

 zero
 

Constructor & Destructor Documentation

◆ __init__() [1/2]

__init__ (   self,
float  distance,
Direction  direction 
)

Create a new spherical vector.

Parameters
distanceThe length of the vector
directionThe direction of the vector

Reimplemented from Polar.

◆ __init__() [2/2]

__init__ (   self,
float  distance,
Direction  direction 
)

Create a new spherical vector.

Parameters
distanceThe length of the vector
directionThe direction of the vector

Reimplemented from Polar.

Member Function Documentation

◆ Degrees() [1/2]

Degrees ( float  distance,
float  horizontal,
float  vertical 
)

Create sperical vector without using the Direction type.

All given angles are in degrees

Parameters
distanceThe distance in meters
horizontalThe horizontal angle in degrees
verticalThe vertical angle in degrees
Returns
The spherical vector

Reimplemented from Polar.

◆ Radians() [1/2]

Radians ( float  distance,
float  horizontal,
float  vertical 
)

Create sperical vector without using the Direction type.

All given angles are in radians

Parameters
distanceThe distance in meters
horizontalThe horizontal angle in radians
verticalThe vertical angle in radians
Returns
The spherical vector

Reimplemented from Polar.

◆ FromVector3() [1/2]

FromVector3 ( Vector3  v)
static

Create a Spherical coordinate from a Vector3 coordinate.

Parameters
vThe vector coordinate
Returns
The spherical coordinate

◆ ToVector3() [1/2]

Vector3 ToVector3 (   self)

Convert the spherical coordinate to a Vector3 coordinate.

Returns
The vector coordinate

◆ __eq__() [1/2]

bool __eq__ (   self,
  other 
)

Check if this vector is equal to the given vector.

Parameters
vThe vector to check against
Returns
true if it is identical to the given vector
Note
This uses float comparison to check equality which may have strange effects. Equality on floats should be avoided.

Reimplemented from Polar.

◆ Normalized() [1/2]

float Normalized (   self)

Reimplemented from Polar.

◆ __neg__() [1/2]

__neg__ (   self)

Negate the vector.

Returns
The negated vector This will negate the direction. Distance will stay the same.

Reimplemented from Polar.

◆ __sub__() [1/2]

__sub__ (   self,
  other 
)

Subtract a spherical vector from this vector.

Parameters
otherThe vector to subtract
Returns
The result of the subtraction

Reimplemented from Polar.

◆ __add__() [1/2]

__add__ (   self,
  other 
)

Add a spherical vector to this vector.

Parameters
otherThe vector to add
Returns
The result of the addition

Reimplemented from Polar.

◆ __mul__() [1/2]

__mul__ (   self,
  factor 
)

Scale the vector uniformly up.

Parameters
factorThe scaling factor
Returns
The scaled vector
Remarks
This operation will scale the distance of the vector. The angle will be unaffected.

Reimplemented from Polar.

◆ __truediv__() [1/2]

__truediv__ (   self,
  factor 
)

Scale the vector uniformly down.

Parameters
factorThe scaling factor
Returns
The scaled vector
Remarks
This operation will scale the distance of the vector. The angle will be unaffected.

Reimplemented from Polar.

◆ Distance() [1/2]

float Distance (   v1,
  v2 
)
static

Calculate the distance between two spherical coordinates.

Parameters
s1The first coordinate
s2The second coordinate
Returns
The distance between the coordinates in meters

Reimplemented from Polar.

◆ Angle() [1/2]

Angle Angle (   s1,
  s2 
)
static

Calculate the unsigned angle between two spherical vectors.

Parameters
s1The first vector
s2The second vector
Returns
The unsigned angle between the vectors [0..179.9999999..., -180]
Remarks
the strange range is caused by the 2s complement signed values which has range [minvalue..maxvalue). This is a hardware limitation, not something we can change.

Reimplemented from Polar.

◆ SignedAngle() [1/2]

Angle SignedAngle (   s1,
  s2,
  axis 
)

Calculate the signed angle between two spherical vectors.

Parameters
s1The first vector
s2The second vector
axisThe axis around which the angle is calculated
Returns
The signed angle between the vectors

Reimplemented from Polar.

◆ Rotate() [1/2]

Rotate (   s,
Angle  horizontal,
Angle  vertical 
)
static

Rotate a spherical vector.

Parameters
sThe vector to rotate
horizontalThe horizontal rotation angle in local space
verticalThe vertical rotation angle in local space
Returns
The rotated vector

◆ Degrees() [2/2]

Degrees ( float  distance,
float  horizontal,
float  vertical 
)

Create sperical vector without using the Direction type.

All given angles are in degrees

Parameters
distanceThe distance in meters
horizontalThe horizontal angle in degrees
verticalThe vertical angle in degrees
Returns
The spherical vector

Reimplemented from Polar.

◆ Radians() [2/2]

Radians ( float  distance,
float  horizontal,
float  vertical 
)

Create sperical vector without using the Direction type.

All given angles are in radians

Parameters
distanceThe distance in meters
horizontalThe horizontal angle in radians
verticalThe vertical angle in radians
Returns
The spherical vector

Reimplemented from Polar.

◆ FromVector3() [2/2]

FromVector3 ( Vector3  v)
static

Create a Spherical coordinate from a Vector3 coordinate.

Parameters
vThe vector coordinate
Returns
The spherical coordinate

◆ ToVector3() [2/2]

Vector3 ToVector3 (   self)

Convert the spherical coordinate to a Vector3 coordinate.

Returns
The vector coordinate

◆ __eq__() [2/2]

bool __eq__ (   self,
  other 
)

Check if this vector is equal to the given vector.

Parameters
vThe vector to check against
Returns
true if it is identical to the given vector
Note
This uses float comparison to check equality which may have strange effects. Equality on floats should be avoided.

Reimplemented from Polar.

◆ isclose()

isclose (   self,
  other,
  rel_tol = 1e-9,
  abs_tol = 1e-8 
)

Reimplemented from Polar.

◆ Normalized() [2/2]

float Normalized (   self)

Reimplemented from Polar.

◆ __neg__() [2/2]

__neg__ (   self)

Negate the vector.

Returns
The negated vector This will negate the direction. Distance will stay the same.

Reimplemented from Polar.

◆ __sub__() [2/2]

__sub__ (   self,
  other 
)

Subtract a spherical vector from this vector.

Parameters
otherThe vector to subtract
Returns
The result of the subtraction

Reimplemented from Polar.

◆ __add__() [2/2]

__add__ (   self,
  other 
)

Add a spherical vector to this vector.

Parameters
otherThe vector to add
Returns
The result of the addition

Reimplemented from Polar.

◆ __mul__() [2/2]

__mul__ (   self,
  factor 
)

Scale the vector uniformly up.

Parameters
factorThe scaling factor
Returns
The scaled vector
Remarks
This operation will scale the distance of the vector. The angle will be unaffected.

Reimplemented from Polar.

◆ __truediv__() [2/2]

__truediv__ (   self,
  factor 
)

Scale the vector uniformly down.

Parameters
factorThe scaling factor
Returns
The scaled vector
Remarks
This operation will scale the distance of the vector. The angle will be unaffected.

Reimplemented from Polar.

◆ Distance() [2/2]

float Distance (   v1,
  v2 
)
static

Calculate the distance between two spherical coordinates.

Parameters
s1The first coordinate
s2The second coordinate
Returns
The distance between the coordinates in meters

Reimplemented from Polar.

◆ Angle() [2/2]

Angle Angle (   s1,
  s2 
)
static

Calculate the unsigned angle between two spherical vectors.

Parameters
s1The first vector
s2The second vector
Returns
The unsigned angle between the vectors [0..179.9999999..., -180]
Remarks
the strange range is caused by the 2s complement signed values which has range [minvalue..maxvalue). This is a hardware limitation, not something we can change.

Reimplemented from Polar.

◆ SignedAngle() [2/2]

Angle SignedAngle (   s1,
  s2,
  axis 
)

Calculate the signed angle between two spherical vectors.

Parameters
s1The first vector
s2The second vector
axisThe axis around which the angle is calculated
Returns
The signed angle between the vectors

Reimplemented from Polar.

◆ Rotate() [2/2]

Rotate (   s,
Angle  horizontal,
Angle  vertical 
)
static

Rotate a spherical vector.

Parameters
sThe vector to rotate
horizontalThe horizontal rotation angle in local space
verticalThe vertical rotation angle in local space
Returns
The rotated vector

Member Data Documentation

◆ distance

distance

The direction of the vector.

Normalizing such that distance >= 0


The documentation for this class was generated from the following files: