SphericalPosition¶
struct SphericalPosition
Spherical coordinates representation.
Describes the coordinates of a point on a sphere's surface, relative to the center of that sphere.
Operators¶
Name | Description |
---|---|
operator== | Compares two spherical positions for equality. |
operator!= | Compares two spherical positions for inequality. |
Functions¶
Name | Description |
---|---|
FromWorldSpace | Creates a spherical position from a 3D position in world space. |
ForHRTF | Creates a spherical position from a 3D position in world space. |
FromDegrees | Creates a spherical position from given azimuth and elevation in degrees. |
SphericalPosition | Creates a spherical position with default values (azimuth = 0, elevation = 0, radius = 1). |
SphericalPosition | Creates a spherical position with given azimuth, elevation, and radius. |
FlipAzimuth | Flips the azimuth of the spherical position and returns a new instance. |
Rotate | Rotates the spherical position with the given rotation and returns a new instance. |
ToCartesian | Converts the spherical position to a 3D position in world space. |
GetAzimuth | Gets the azimuth in radians of the spherical position. |
GetElevation | Gets the elevation in radians of the spherical position. |
GetRadius | Gets the distance from the center of the sphere to the point. |
SetAzimuth | Sets the azimuth in radians of the spherical position. |
SetElevation | Sets the elevation in radians of the spherical position. |
SetRadius | Sets the distance from the center of the sphere to the point. |
Operator Details¶
operator!=¶
bool operator!=(const SphericalPosition& other) const
Compares two spherical positions for inequality.
- Parameter
other
- The other spherical position to compare with.
- Return
true
if the spherical positions are not equal,false
otherwise.
operator==¶
bool operator==(const SphericalPosition& other) const
Compares two spherical positions for equality.
- Parameter
other
- The other spherical position to compare with.
- Return
true
if the spherical positions are equal,false
otherwise.
Function Details¶
FlipAzimuth¶
[[nodiscard]] SphericalPosition FlipAzimuth() const
Flips the azimuth of the spherical position and returns a new instance.
- Return
- A new spherical position with the azimuth flipped.
ForHRTF¶
static SphericalPosition ForHRTF(const AmVec3& position)
Creates a spherical position from a 3D position in world space.
This method is optimized for use in HRTF (Head-Related Transfer Function) space, where the azimuth is rotated 90 degrees around the z-axis.
- Parameter
position
- The position in world space.
FromDegrees¶
static SphericalPosition FromDegrees(AmReal32 azimuthDegrees, AmReal32 elevationDegrees, AmReal32 radius = 1.0f)
Creates a spherical position from given azimuth and elevation in degrees.
- Parameter
azimuthDegrees
- The azimuth in degrees.
- Parameter
elevationDegrees
- The elevation in degrees.
- Parameter
radius
- The distance from the center of the sphere to the point.
- Return
- A spherical position representing the given azimuth and elevation in degrees.
FromWorldSpace¶
static SphericalPosition FromWorldSpace(const AmVec3& position)
Creates a spherical position from a 3D position in world space.
- Parameter
position
- The position in world space.
GetAzimuth¶
[[nodiscard]] inline AmReal32 GetAzimuth() const
Gets the azimuth in radians of the spherical position.
- Return
- The azimuth in radians of the spherical position.
GetElevation¶
[[nodiscard]] inline AmReal32 GetElevation() const
Gets the elevation in radians of the spherical position.
- Return
- The elevation in radians of the spherical position.
GetRadius¶
[[nodiscard]] inline AmReal32 GetRadius() const
Gets the distance from the center of the sphere to the point.
- Return
- The distance from the center of the sphere to the point.
Rotate¶
[[nodiscard]] SphericalPosition Rotate(AmQuat rotation) const
Rotates the spherical position with the given rotation and returns a new instance.
- Parameter
rotation
- The rotation to apply to the spherical position.
- Return
- A rotated spherical position.
SetAzimuth¶
inline void SetAzimuth(AmReal32 azimuth)
Sets the azimuth in radians of the spherical position.
- Parameter
azimuth
- The new azimuth in radians.
SetElevation¶
inline void SetElevation(AmReal32 elevation)
Sets the elevation in radians of the spherical position.
- Parameter
elevation
- The new elevation in radians.
SetRadius¶
inline void SetRadius(AmReal32 radius)
Sets the distance from the center of the sphere to the point.
- Parameter
radius
- The new distance from the center of the sphere to the point.
SphericalPosition¶
SphericalPosition() = default
Creates a spherical position with default values (azimuth = 0, elevation = 0, radius = 1).
SphericalPosition(AmReal32 azimuth, AmReal32 elevation, AmReal32 radius = 1.0f)
Creates a spherical position with given azimuth, elevation, and radius.
- Parameter
azimuth
- The rotation around the z-axis in radians.
- Parameter
elevation
- The rotation around the x-axis in radians.
- Parameter
radius
- The distance from the center of the sphere to the point.
ToCartesian¶
[[nodiscard]] AmVec3 ToCartesian() const
Converts the spherical position to a 3D position in world space.
- Return
- A 3D position in world space corresponding to the spherical position.