shz::vec3
3D Vector type
C++ structure for representing a 3-dimensional vector.
- Header:
#include <sh4zam/shz_vector.hpp>(source) - C type:
shz_vec3_t(layout-compatible; the C API accepts it directly) - Bases:
shz::vecN< vec3, shz_vec3_t, 3 >
Static functions
Section titled “Static functions”orthonormalize
Section titled “orthonormalize”static auto orthonormalize(const vec3 &in1, const vec3 &in2) noexceptstatic void orthonormalize(const vec3 &in1, const vec3 &in2, vec3 *out1, vec3 *out2) noexceptReturns 2 3D vectors which are normalized and orthogonal to the two input vectors as a std::pair<>.
Calls: shz_vec3_orthonormalize()
cubic_hermite
Section titled “cubic_hermite”static vec3 cubic_hermite(const vec3 &v1, const vec3 &tangent1, const vec3 &v2, const vec3 &tangent2, float amount) noexceptCalculates the cubic hermite interpolation between two vectors and their tangents.
Calls: shz_vec3_cubic_hermite()
from_angles
Section titled “from_angles”static vec3 from_angles(float azimuth_rads, float elevation_rads) noexceptReturns a 3D vector which forms the given angles with the +X axis, in radians.
Calls: shz_vec3_from_angles()
from_angles_deg
Section titled “from_angles_deg”static vec3 from_angles_deg(float azimuth_deg, float elevation_deg) noexceptReturns a 3D vector which forms the given angles with the +X axis, in degrees.
Calls: shz_vec3_from_angles_deg()
static CppType shz::vecN< CRTP, C, R >::from(const T &raw) noexceptConversion operator for going from a layout-compatible vector type to a SH4ZAM vector type.
Inherited from shz::vecN.
static CppType shz::vecN< CRTP, C, R >::lerp(const CppType &start, const CppType &end, float t) noexceptReturns the vector that is linearly interpolated between the two given vectors by the 0.0f-1.0f factor, t.
Calls: shz_vec3_lerp() (inherited from shz::vecN)
smoothstep
Section titled “smoothstep”static CppType shz::vecN< CRTP, C, R >::smoothstep(const CppType &vec, T &&edge0, T &&edge1) noexceptReturns a vector where each component is smoothly interpolated from 0 to 1 between edge0 and edge1.
Calls: shz_vec3_smoothstep() (inherited from shz::vecN)
smoothstep_safe
Section titled “smoothstep_safe”static CppType shz::vecN< CRTP, C, R >::smoothstep_safe(const CppType &vec, T &&edge0, T &&edge1) noexceptReturns a vector where each component is smoothly interpolated from 0 to 1 between edge0 and edge1.
Calls: shz_vec3_smoothstep_safe() (inherited from shz::vecN)
static CppType shz::vecN< CRTP, C, R >::step(const CppType &vec, T &&edge) noexceptCompares each component of the vector to the edge. 0 returned in that component if x[i] < edge. Otherwise the component is 1.
Calls: shz_vec3_step() (inherited from shz::vecN)
Members
Section titled “Members”rotate_x
Section titled “rotate_x”vec3 rotate_x(float angle) const noexceptvec3 rotate_x(uint16_t radians16) const noexceptRotates a 3D vector about the X axis by the given number of radians.
Calls: shz_vec3_rotate_x(), shz_vec3_rotate_x_u16()
rotate_y
Section titled “rotate_y”vec3 rotate_y(float angle) const noexceptvec3 rotate_y(uint16_t radians16) const noexceptRotates a 3D vector about the Y axis by the given number of radians.
Calls: shz_vec3_rotate_y(), shz_vec3_rotate_y_u16()
rotate_z
Section titled “rotate_z”vec3 rotate_z(float angle) const noexceptvec3 rotate_z(uint16_t radians16) const noexceptRotates a 3D vector about the Z axis by the given number of radians.
Calls: shz_vec3_rotate_z(), shz_vec3_rotate_z_u16()
rotate_xyz
Section titled “rotate_xyz”vec3 rotate_xyz(float x, float y, float z) const noexceptvec3 rotate_xyz(const vec3 &angles) const noexceptvec3 rotate_xyz(uint16_t x, uint16_t y, uint16_t z) const noexceptRotates a 3D vector by a X-Y-Z rotation, with the corresponding angles given in radians.
Calls: shz_vec3_rotate_xyz(), shz_vec3_rotate_xyz_u16()
rotate_zyx
Section titled “rotate_zyx”vec3 rotate_zyx(float z, float y, float x) const noexceptvec3 rotate_zyx(const vec3 &angles) const noexceptvec3 rotate_zyx(uint16_t z, uint16_t y, uint16_t x) const noexceptRotates a 3D vector by a Z-Y-X rotation, with the corresponding angles given in radians.
Calls: shz_vec3_rotate_zyx(), shz_vec3_rotate_zyx_u16()
rotate_zxy
Section titled “rotate_zxy”vec3 rotate_zxy(float z, float x, float y) const noexceptvec3 rotate_zxy(const vec3 &angles) const noexceptvec3 rotate_zxy(uint16_t z, uint16_t x, uint16_t y) const noexceptRotates a 3D vector by a Z-X-Y rotation, with the corresponding angles given in radians.
Calls: shz_vec3_rotate_zxy(), shz_vec3_rotate_zxy_u16()
rotate_yxz
Section titled “rotate_yxz”vec3 rotate_yxz(float y, float x, float z) const noexceptvec3 rotate_yxz(const vec3 &angles) const noexceptvec3 rotate_yxz(uint16_t y, uint16_t x, uint16_t z) const noexceptRotates a 3D vector by a Y-X-Z rotation, with the corresponding angles given in radians.
Calls: shz_vec3_rotate_yxz(), shz_vec3_rotate_yxz_u16()
rotate
Section titled “rotate”vec3 rotate(float angle, const vec3 &axis) const noexceptvec3 rotate(float angle, float x, float y, float z) const noexceptvec3 rotate(uint16_t radians16, const vec3 &axis) const noexceptvec3 rotate(uint16_t radians16, float x, float y, float z) const noexceptRotates a 3D vector by the given number of radians about the given axis.
Calls: shz_vec3_rotate(), shz_vec3_init(), shz_vec3_rotate_u16()
rotate_dir
Section titled “rotate_dir”vec3 rotate_dir(float angle, const vec3 &axis) const noexceptvec3 rotate_dir(float angle, float x, float y, float z) const noexceptvec3 rotate_dir(uint16_t radians16, const vec3 &axis) const noexceptvec3 rotate_dir(uint16_t radians16, float x, float y, float z) const noexceptRotates a 3D vector by the given number of radians about the given unit-length axis.
Calls: shz_vec3_rotate_dir(), shz_vec3_init(), shz_vec3_rotate_dir_u16()
vec3()=defaultvec3(const shz_vec3_t &other) noexceptvec3(float v) noexceptvec3(float x, float y, float z) noexceptvec3(const shz::vec2 &xy, float z) noexceptvec3(float x, const shz::vec2 &yz) noexceptvec3(const sincos &azimuth, const sincos &elevation) noexceptDefault constructor: does nothing.
vec2 xy() const noexceptvec3 cross(const vec3 &other) const noexceptReturns a 3D vector which forms the given angles with the +X axis.
Calls: shz_vec3_cross()
triple
Section titled “triple”float triple(const vec3 &b, const vec3 &c) const noexceptReturns the 3D vector "triple product" between the given vector and vectors a and b.
Calls: shz_vec3_triple()
vec3 perp() const noexceptReturns a 3D vector which is perpendicular to this vector.
Calls: shz_vec3_perp()
barycenter
Section titled “barycenter”vec3 barycenter(const vec3 &a, const vec3 &b, const vec3 &c) const noexceptComputes the barycentric coordinates <u, v, w> for the given 3D vector, within the plane of the triangle formed by the given vertices, a, b, and c.
Calls: shz_vec3_barycenter()
shz::vecN< CRTP, C, R >::vecN() noexcept=defaultshz::vecN< CRTP, C, R >::vecN(const vecN &other) noexcept=defaultshz::vecN< CRTP, C, R >::vecN(const CType &other) noexceptshz::vecN< CRTP, C, R >::vecN(const volatile CType &other) noexceptDefault constructor, does nothing.
float shz::vecN< CRTP, C, R >::dot(const CppType &other) const noexceptvec2 shz::vecN< CRTP, C, R >::dot(const CppType &v1, const CppType &v2) const noexceptvec3 shz::vecN< CRTP, C, R >::dot(const CppType &v1, const CppType &v2, const CppType &v3) const noexceptReturns the dot product of the given vector and another.
CppType shz::vecN< CRTP, C, R >::abs() const noexceptReturns a new vector whose components are the absolute value of the given vector.
Calls: shz_vec3_abs() (inherited from shz::vecN)
angle_between
Section titled “angle_between”float shz::vecN< CRTP, C, R >::angle_between(const CppType &other) const noexceptReturns the angle between the given vector and another, in radians.
Calls: shz_vec3_angle_between() (inherited from shz::vecN)
angles
Section titled “angles”auto shz::vecN< CRTP, C, R >::angles() const noexceptReturns the angle(s) created between the given vector axis and the +X axis, in radians.
Calls: shz_vec3_angles() (inherited from shz::vecN)
bisector
Section titled “bisector”CppType shz::vecN< CRTP, C, R >::bisector(const CppType &other) const noexceptReturns the non-normalized vector pointing down the middle of the angle formed by this vector and another.
Calls: shz_vec3_bisector() (inherited from shz::vecN)
CppType shz::vecN< CRTP, C, R >::ceil() const noexceptReturns a new vector with the component-wise ceil of the given vector.
Calls: shz_vec3_ceil() (inherited from shz::vecN)
CppType shz::vecN< CRTP, C, R >::clamp(float min, float max) const noexceptReturns a new vector whose values are the clamped components of the given vector.
Calls: shz_vec3_clamp() (inherited from shz::vecN)
CppType & shz::vecN< CRTP, C, R >::deref(const T *raw) noexceptConversion operator for accessing an existing pointer type as though it were a refrence to a SH4ZAM type.
Inherited from shz::vecN.
direction
Section titled “direction”CppType shz::vecN< CRTP, C, R >::direction() const noexceptReturns the direction vector resulting from normalizing the given vector.
Calls: shz_vec3_normalize() (inherited from shz::vecN)
direction_or
Section titled “direction_or”CppType shz::vecN< CRTP, C, R >::direction_or(const CppType &alt) const noexceptReturns the direction vector of a given vector, or alt if it has a magnitude of 0.0f.
Calls: shz_vec3_normalize_or() (inherited from shz::vecN)
direction_safe
Section titled “direction_safe”CppType shz::vecN< CRTP, C, R >::direction_safe() const noexceptReturns the direction vector of a given vector, safely protecting against division-by-zero.
Calls: shz_vec3_normalize_safe() (inherited from shz::vecN)
distance
Section titled “distance”float shz::vecN< CRTP, C, R >::distance(const CppType &other) const noexceptReturns the magnitude of the difference between two vectors as their distance.
Calls: shz_vec3_distance() (inherited from shz::vecN)
distance_sqr
Section titled “distance_sqr”float shz::vecN< CRTP, C, R >::distance_sqr(const CppType &other) const noexceptReturns the value of the distance between two vectors squared (faster than actual distance).
Calls: shz_vec3_distance_sqr() (inherited from shz::vecN)
CppType shz::vecN< CRTP, C, R >::div(const CppType &rhs) const noexceptReturns a new vector whose components are those of the given vector divided by rhs.
Calls: shz_vec3_div() (inherited from shz::vecN)
div_fsrra
Section titled “div_fsrra”CppType shz::vecN< CRTP, C, R >::div_fsrra(const CppType &rhs) const noexceptReturns a new vector whose components are those of the given vector divided by rhs, using a fast approximation which requires rhs to have positive components.
Calls: shz_vec3_div_fsrra() (inherited from shz::vecN)
CppType shz::vecN< CRTP, C, R >::divf(float denom) const noexceptReturns a new vector whose components are those of the given vector divided by the scalar denom.
Calls: shz_vec3_divf() (inherited from shz::vecN)
divf_fsrra
Section titled “divf_fsrra”CppType shz::vecN< CRTP, C, R >::divf_fsrra(float denom) const noexceptReturns a new vector whose components are those of the given vector divided by the scalar denom, using a fast approximation which requires denom to be positive.
Calls: shz_vec3_divf_fsrra() (inherited from shz::vecN)
CppType shz::vecN< CRTP, C, R >::floor() const noexceptReturns a new vector with the component-wise floor of the given vector.
Calls: shz_vec3_floor() (inherited from shz::vecN)
CppType shz::vecN< CRTP, C, R >::fract() const noexceptReturns a new vector with the fractional part of each component.
Calls: shz_vec3_fract() (inherited from shz::vecN)
half_angle
Section titled “half_angle”CppType shz::vecN< CRTP, C, R >::half_angle(const CppType &other) const noexceptReturns the unit vector pointing halfway between this vector and another.
Calls: shz_vec3_half_angle() (inherited from shz::vecN)
CppType shz::vecN< CRTP, C, R >::inv() const noexceptReturns a new vector whose components are the reciprocal values of the given vector.
Calls: shz_vec3_inv() (inherited from shz::vecN)
inv_fsrra
Section titled “inv_fsrra”CppType shz::vecN< CRTP, C, R >::inv_fsrra() const noexceptReturns a new vector whose components are the reciprocal values of the given vector, using a fast approximation which requires positive components.
Calls: shz_vec3_inv_fsrra() (inherited from shz::vecN)
inv_sqrtf
Section titled “inv_sqrtf”CppType shz::vecN< CRTP, C, R >::inv_sqrtf() const noexceptReturns a new vector whose components are the inverse square root of the given vector.
Calls: shz_vec3_inv_sqrtf() (inherited from shz::vecN)
magnitude
Section titled “magnitude”float shz::vecN< CRTP, C, R >::magnitude() const noexceptReturns the magnitude of the given vector, safely returning 0.0f for a zero-length vector.
Calls: shz_vec3_magnitude() (inherited from shz::vecN)
magnitude_fsrra
Section titled “magnitude_fsrra”float shz::vecN< CRTP, C, R >::magnitude_fsrra() const noexceptReturns the magnitude of the given vector, unsafely, using FSRRA. Divides by zero for a zero-length vector.
Calls: shz_vec3_magnitude_fsrra() (inherited from shz::vecN)
magnitude_inv
Section titled “magnitude_inv”float shz::vecN< CRTP, C, R >::magnitude_inv() const noexceptReturns the inverse magnitude of the given vector, safely returning 0.0f for a zero-length vector.
Calls: shz_vec3_magnitude_inv() (inherited from shz::vecN)
magnitude_inv_fsrra
Section titled “magnitude_inv_fsrra”float shz::vecN< CRTP, C, R >::magnitude_inv_fsrra() const noexceptReturns the inverse magnitude of the given vector, unsafely, using FSRRA. Divides by zero for a zero-length vector.
Calls: shz_vec3_magnitude_inv_fsrra() (inherited from shz::vecN)
magnitude_sqr
Section titled “magnitude_sqr”float shz::vecN< CRTP, C, R >::magnitude_sqr() const noexceptReturns the squared magnitude of the given vector.
Calls: shz_vec3_magnitude_sqr() (inherited from shz::vecN)
float shz::vecN< CRTP, C, R >::max() const noexceptReturns the maximum value of every element within the vector.
Calls: shz_vec3_max() (inherited from shz::vecN)
CppType shz::vecN< CRTP, C, R >::maxv(const CppType &other) const noexceptReturns a new vector with the component-wise maximum of two vectors.
Calls: shz_vec3_maxv() (inherited from shz::vecN)
float shz::vecN< CRTP, C, R >::min() const noexceptReturns the minimum value of every element within the vector.
Calls: shz_vec3_min() (inherited from shz::vecN)
CppType shz::vecN< CRTP, C, R >::minv(const CppType &other) const noexceptReturns a new vector with the component-wise minimum of two vectors.
Calls: shz_vec3_minv() (inherited from shz::vecN)
CppType shz::vecN< CRTP, C, R >::move(const CppType &target, float maxdist) const noexceptMoves the given vector towards the target by the given maxdist.
Calls: shz_vec3_move() (inherited from shz::vecN)
CppType shz::vecN< CRTP, C, R >::neg() const noexceptReturns a new vector whose components are the negative values of the given vector.
Calls: shz_vec3_neg() (inherited from shz::vecN)
normalize
Section titled “normalize”void shz::vecN< CRTP, C, R >::normalize() noexceptNormalizes the given vector.
Calls: shz_vec3_normalize() (inherited from shz::vecN)
normalize_or
Section titled “normalize_or”void shz::vecN< CRTP, C, R >::normalize_or(const CppType &alt) noexceptNormalizes the given vector, or sets it to alt if it has a magnitude of 0.0f.
Calls: shz_vec3_normalize_or() (inherited from shz::vecN)
normalize_safe
Section titled “normalize_safe”void shz::vecN< CRTP, C, R >::normalize_safe() noexceptNormalizes the given vector, safely protecting against division-by-zero.
Calls: shz_vec3_normalize_safe() (inherited from shz::vecN)
normalized
Section titled “normalized”CppType shz::vecN< CRTP, C, R >::normalized() const noexceptReturn the normalized vector.
Calls: shz_vec3_normalize() (inherited from shz::vecN)
normalized_or
Section titled “normalized_or”CppType shz::vecN< CRTP, C, R >::normalized_or(const CppType &alt) const noexceptReturn the normalized vector, or alt if it has a magnitude of 0.0f.
Calls: shz_vec3_normalize_or() (inherited from shz::vecN)
normalized_safe
Section titled “normalized_safe”CppType shz::vecN< CRTP, C, R >::normalized_safe() const noexceptReturn the normalized vector, safely protecting against division-by-zero.
Calls: shz_vec3_normalize_safe() (inherited from shz::vecN)
operator*=
Section titled “operator*=”CppType & shz::vecN< CRTP, C, R >::operator*=(const CppType &other) noexceptOverloaded multiplication assignment operator, multiplies and accumulates a vector onto the left-hand vector.
Inherited from shz::vecN.
operator+=
Section titled “operator+=”CppType & shz::vecN< CRTP, C, R >::operator+=(const CppType &other) noexceptOverloaded operator for adding and accumulating a vector onto another.
Inherited from shz::vecN.
operator-=
Section titled “operator-=”CppType & shz::vecN< CRTP, C, R >::operator-=(const CppType &other) noexceptOverloaded subtraction assignment operator, subtracts a vector from the left-hand vector.
Inherited from shz::vecN.
operator/=
Section titled “operator/=”CppType & shz::vecN< CRTP, C, R >::operator/=(const CppType &other) noexceptOverloaded division assignment operator, divides the left vector by the right, assigning the left to the result.
Inherited from shz::vecN.
project
Section titled “project”CppType shz::vecN< CRTP, C, R >::project(const CppType &onto) const noexceptReturns the vector created from projecting the given vector onto another.
Calls: shz_vec3_project() (inherited from shz::vecN)
project_safe
Section titled “project_safe”CppType shz::vecN< CRTP, C, R >::project_safe(const CppType &onto) const noexceptReturns the vector created from projecting the given vector onto another, safely protecting against division-by-zero.
Calls: shz_vec3_project_safe() (inherited from shz::vecN)
reflect
Section titled “reflect”CppType shz::vecN< CRTP, C, R >::reflect(const CppType &normal) const noexceptReturns the vector created from reflecting the given vector over the normal of a surface.
Calls: shz_vec3_reflect() (inherited from shz::vecN)
refract
Section titled “refract”CppType shz::vecN< CRTP, C, R >::refract(const CppType &normal, float eta) const noexceptReturns the vector create from refracting the given incidence vector over the normal of a surface, using the given refraction ratio index.
Calls: shz_vec3_refract() (inherited from shz::vecN)
reject
Section titled “reject”CppType shz::vecN< CRTP, C, R >::reject(const CppType &onto) const noexceptReturns the vector created from rejecting the given vector onto another, the component orthogonal to it.
Calls: shz_vec3_reject() (inherited from shz::vecN)
reject_safe
Section titled “reject_safe”CppType shz::vecN< CRTP, C, R >::reject_safe(const CppType &onto) const noexceptReturns the vector created from rejecting the given vector onto another, safely protecting against division-by-zero.
Calls: shz_vec3_reject_safe() (inherited from shz::vecN)
CppType shz::vecN< CRTP, C, R >::round() const noexceptReturns a new vector with the component-wise rounding of the given vector.
Calls: shz_vec3_round() (inherited from shz::vecN)
saturate
Section titled “saturate”CppType shz::vecN< CRTP, C, R >::saturate() const noexceptReturns a new vector with each component clamped to [0, 1].
Calls: shz_vec3_saturate() (inherited from shz::vecN)
CppType shz::vecN< CRTP, C, R >::sign() const noexceptReturns a new vector with the sign of each component (-1, 0, or 1).
Calls: shz_vec3_sign() (inherited from shz::vecN)
CppType shz::vecN< CRTP, C, R >::sqrtf() const noexceptReturns a new vector whose components are the square root of the given vector.
Calls: shz_vec3_sqrtf() (inherited from shz::vecN)
sqrtf_fsrra
Section titled “sqrtf_fsrra”CppType shz::vecN< CRTP, C, R >::sqrtf_fsrra() const noexceptReturns a new vector whose components are the fast approximate square root of the given vector.
Calls: shz_vec3_sqrtf_fsrra() (inherited from shz::vecN)
swizzle
Section titled “swizzle”CppType shz::vecN< CRTP, C, R >::swizzle() const noexceptSwizzle oeprator which takes a compile-time list of indices as non-type template arguments for the index each element should use as its new value.
Calls: shz_vec3_swizzle() (inherited from shz::vecN)
T shz::vecN< CRTP, C, R >::to() const noexceptConversion operator for going from a SH4ZAM vector type to another layout-compatible type.
Inherited from shz::vecN.