Skip to content

Latest commit

 

History

History
756 lines (400 loc) · 38.4 KB

Math.md

File metadata and controls

756 lines (400 loc) · 38.4 KB

Math

Members

enum Axis

Values Descriptions
None
X
Y
Z

public inline float Pow(float x,float e)

public inline float Cos(float x)

public inline float Sin(float x)

public inline float Tan(float x)

public inline float Acos(float x)

public inline float Asin(float x)

public inline float Atan(float x)

public inline float Atan2(float y,float x)

public inline float Sqrt(float x)

public inline uint32_t Mod(uint32_t i,uint32_t n)

public inline int Mod(int32_t i,int32_t n)

public inline float Mod(float f,float n)

public inline int32_t Ceil(float f)

public inline int32_t Floor(float f)

public inline int32_t Round(float f)

public inline float Abs(float x)

public inline int32_t Abs(int32_t x)

public template<>
inline auto Min(T0 v0,T1 v1)

public template<>
inline auto Max(T0 v0,T1 v1)

public template<>
inline auto Min(T0 v0,T1 v1,T2 v2)

public template<>
inline auto Max(T0 v0,T1 v1,T2 v2)

public template<>
inline T Clip(T x,T min,T max)

public inline float Clip01(float x)

public template<>
T0 Lerp(T0 start,T0 end,T1 t)

public inline float LerpAngle(float start,float end,float t)

public inline float Delerp(float start,float end,float value)

public inline float Delerp01(float start,float end,float value)

public template<>
T DtLerp(T start,float snappiness,float dt,T end)

public template<>
T DtSlerp(T start,float snappiness,float dt,T end)

public inline float DtLerpAngle(float start,float snappiness,float dt,float end)

public template<>
T CosineInterpolate(T start,T end,float t)

public inline float DegToRad(float degrees)

public inline float RadToDeg(float radians)

public template<>
constexpr T MaxValue()

public template<>
constexpr T MinValue()

public template<>
constexpr float MaxValue< float >()

public template<>
constexpr float MinValue< float >()

public template<>
constexpr double MaxValue< double >()

public template<>
constexpr double MinValue< double >()

public void RandomSeed()

public inline float Random01(uint64_t & seed)

public inline bool RandomBool(uint64_t & seed)

public inline int32_t Random(int32_t minInclusive,int32_t maxExclusive,uint64_t & seed)

public inline float Random(float min,float max,uint64_t & seed)

public template<>
struct AE_ALIGN(16)

public inline std::ostream & operator<<(std::ostream & os,const Matrix4 & mat)

public inline std::ostream & operator<<(std::ostream & os,const Quaternion & quat)

public template<>
inline std::ostream & operator<<(std::ostream & os,const IntT< T > & v)

public std::ostream & operator<<(std::ostream & os,AABB aabb)

public bool IntersectRayTriangle(ae::Vec3 p,ae::Vec3 ray,ae::Vec3 a,ae::Vec3 b,ae::Vec3 c,bool ccw,bool cw,ae::Vec3 * pOut,ae::Vec3 * nOut,float * tOut)

public Vec3 ClosestPointOnTriangle(ae::Vec3 p,ae::Vec3 a,ae::Vec3 b,ae::Vec3 c)



ae::RandomValue class

public inline RandomValue(uint64_t & seed)

public inline RandomValue(T min,T max,uint64_t & seed)

public inline RandomValue(T value,uint64_t & seed)

public inline void SetMin(T min)

public inline void SetMax(T max)

public inline T GetMin() const

public inline T GetMax() const

public inline T Get() const

public inline operator T() const



ae::Matrix4 class

public float data

public Matrix4() = default

public Matrix4(const Matrix4 &) = default

public inline bool operator==(const Matrix4 & o) const

public inline bool operator!=(const Matrix4 & o) const

public Vec4 operator*(const Vec4 & v) const

public Matrix4 operator*(const Matrix4 & m) const

public void operator*=(const Matrix4 & m)

public void SetTranslation(float x,float y,float z)

public void SetTranslation(const Vec3 & t)

public void SetScale(const Vec3 & s)

public void SetRotation(const class Quaternion & r)

public class Quaternion GetRotation() const

public void SetTranspose()

public void SetInverse()

public Vec3 GetTranslation() const

public Vec3 GetScale() const

public Matrix4 GetTranspose() const

public Matrix4 GetInverse() const

public Matrix4 GetNormalMatrix() const

public Matrix4 GetScaleRemoved() const

public void SetAxis(uint32_t column,const Vec3 & v)

public void SetRow(uint32_t row,const Vec3 & v)

public void SetRow(uint32_t row,const Vec4 & v)

public Vec3 GetAxis(uint32_t column) const

public Vec4 GetRow(uint32_t row) const



ae::Quaternion class

public float i

public float j

public float k

public float r

public float data

public union ae::Quaternion::@12 @13

public Quaternion() = default

public Quaternion(const Quaternion &) = default

public inline Quaternion(const float i,const float j,const float k,const float r)

public inline explicit Quaternion(Vec3 v)

public Quaternion(Vec3 forward,Vec3 up,bool prioritizeUp)

public Quaternion(Vec3 axis,float angle)

public void Normalize()

public bool operator==(const Quaternion & q) const

public bool operator!=(const Quaternion & q) const

public Quaternion & operator*=(const Quaternion & q)

public Quaternion operator*(const Quaternion & q) const

public float Dot(const Quaternion & q) const

public const Quaternion operator*(float s) const

public void AddScaledVector(const Vec3 & v,float s)

public void RotateByVector(const Vec3 & v)

public void SetDirectionXY(const Vec3 & v)

public Vec3 GetDirectionXY() const

public void ZeroXY()

public void GetAxisAngle(Vec3 * axis,float * angle) const

public void AddRotationXY(float rotation)

public Quaternion Nlerp(Quaternion end,float t) const

public Matrix4 GetTransformMatrix() const

public Quaternion GetInverse() const

public Quaternion & SetInverse()

public Vec3 Rotate(Vec3 v) const



ae::Sphere class

public ae::Vec3 center

public float radius

public Sphere() = default

public inline Sphere(ae::Vec3 center,float radius)

public explicit Sphere(const class OBB & obb)

public void Expand(ae::Vec3 p)

public bool IntersectRay(ae::Vec3 origin,ae::Vec3 direction,ae::Vec3 * pOut,float * tOut) const

public bool IntersectTriangle(ae::Vec3 t0,ae::Vec3 t1,ae::Vec3 t2,ae::Vec3 * outNearestIntersectionPoint) const



ae::Plane class

A plane in the form of ax+by+cz+d=0.

This means that n<x,y,z>*d equals the closest point on the plane to the origin.

public Plane() = default

public Plane(ae::Vec3 point,ae::Vec3 normal)

public Plane(ae::Vec4 pointNormal)

public Plane(ae::Vec3 p0,ae::Vec3 p1,ae::Vec3 p2)

public explicit operator Vec4() const

public ae::Vec3 GetNormal() const

public ae::Vec3 GetClosestPointToOrigin() const

public bool IntersectLine(ae::Vec3 p,ae::Vec3 d,ae::Vec3 * hitOut,float * tOut) const

public bool IntersectRay(ae::Vec3 source,ae::Vec3 ray,ae::Vec3 * hitOut,float * tOut) const

public ae::Vec3 GetClosestPoint(ae::Vec3 pos,float * distanceOut) const

public float GetSignedDistance(ae::Vec3 pos) const



ae::Line class

public Line() = default

public Line(ae::Vec3 p0,ae::Vec3 p1)

public ae::Vec3 GetClosest(ae::Vec3 p,float * distance) const

public float GetDistance(ae::Vec3 p,ae::Vec3 * closestOut) const



ae::LineSegment class

public LineSegment() = default

public LineSegment(ae::Vec3 p0,ae::Vec3 p1)

public ae::Vec3 GetClosest(ae::Vec3 p,float * distance) const

public float GetDistance(ae::Vec3 p,ae::Vec3 * closestOut) const

public ae::Vec3 GetStart() const

public ae::Vec3 GetEnd() const

public float GetLength() const



ae::Circle class

public Circle() = default

public Circle(ae::Vec2 point,float radius)

public inline ae::Vec2 GetCenter() const

public inline float GetRadius() const

public inline void SetCenter(ae::Vec2 point)

public inline void SetRadius(float radius)

public bool Intersect(const Circle & other,ae::Vec2 * out) const

public ae::Vec2 GetRandomPoint(uint64_t & seed) const



ae::Frustum class

public explicit Frustum(ae::Matrix4 worldToProjection)

public bool Intersects(const ae::Sphere & sphere) const

public bool Intersects(ae::Vec3 point) const

public ae::Plane GetPlane(ae::Frustum::Plane plane) const

enum Plane

Values Descriptions
Near
Far
Left
Right
Top
Bottom



ae::AABB class

public AABB() = default

public AABB(const AABB &) = default

public AABB(Vec3 p0,Vec3 p1)

public explicit AABB(const Sphere & sphere)

public bool operator==(const AABB & aabb) const

public bool operator!=(const AABB & aabb) const

public void Expand(Vec3 p)

public void Expand(AABB other)

public void Expand(float boundary)

public inline Vec3 GetMin() const

public inline Vec3 GetMax() const

public inline Vec3 GetCenter() const

public inline Vec3 GetHalfSize() const

public Matrix4 GetTransform() const

public bool Contains(Vec3 p) const

public bool Intersect(AABB other) const

public float GetSignedDistanceFromSurface(Vec3 p) const

Returns the distance p is to the surface of the aabb.

The returned value will be negative if p is inside the aabb.

public Vec3 GetClosestPointOnSurface(Vec3 p,bool * containsOut) const

Returns the point on the aabbs surface that is closest to the given point.

If containsOut is provided it will be set to false if the point does not touch the aabb, and true otherwise.

public bool IntersectLine(Vec3 p,Vec3 d,float * t0Out,float * t1Out,ae::Vec3 * n0Out,ae::Vec3 * n1Out) const

Returns true if any point along the line p + d intersects the aabb.

On intersection t0Out will be set so that p + d * t0Out = p0 (where p0 is the first point along the line in the direction of d that is on the surface of the aabb). t1Out will be similarly set but for the last intersection point on the line. n0Out and n1Out will be set to the face normals of the aabb at t0Out and t1Out respectively.

public bool IntersectRay(Vec3 source,Vec3 ray,Vec3 * hitOut,ae::Vec3 * normOut,float * tOut) const

Returns true if the segment [source, source + ray] intersects the aabb (including when source is inside the aabb).

On returning true: hitOut will be set to the first intersection point on the surface (or to source if the ray starts within the aabb). normOut will be set to the normal of the face of the contact point, or to the normal of the nearest face to source if it is inside the aabb. tOut will be set to a value so that source + ray * tOut = hitOut.



ae::OBB class

public OBB() = default

public OBB(const OBB &) = default

public OBB(const Matrix4 & transform)

public void SetTransform(const Matrix4 & transform)

public Matrix4 GetTransform() const

public float GetSignedDistanceFromSurface(Vec3 p) const

Returns the distance p is to the surface of the obb.

The returned value will be negative if p is inside the obb.

public Vec3 GetClosestPointOnSurface(Vec3 p,bool * containsOut) const

Returns the point on the obbs surface that is closest to the given point.

If containsOut is provided it will be set to false if the point does not touch the obb, and true otherwise.

public bool IntersectLine(Vec3 p,Vec3 d,float * t0Out,float * t1Out,ae::Vec3 * n0Out,ae::Vec3 * n1Out) const

Returns true if any point along the line p + d intersects the obb.

On intersection t0Out will be set so that p + d * t0Out = p0 (where p0 is the first point along the line in the direction of d that is on the surface of the obb). t1Out will be similarly set but for the last intersection point on the line. n0Out and n1Out will be set to the face normals of the obb at t0Out and t1Out respectively.

public bool IntersectRay(Vec3 source,Vec3 ray,Vec3 * hitOut,ae::Vec3 * normOut,float * tOut) const

Returns true if the segment [source, source + ray] intersects the obb (including when source is inside the obb).

On returning true: hitOut will be set to the first intersection point on the surface (or to source if the ray starts within the obb). normOut will be set to the normal of the face of the contact point, or to the normal of the nearest face to source if it is inside the obb. tOut will be set to a value so that source + ray * tOut = hitOut.

public AABB GetAABB() const

Returns an AABB that tightly fits this obb.

public inline ae::Vec3 GetCenter() const

public inline ae::Vec3 GetAxis(uint32_t idx) const

public inline ae::Vec3 GetHalfSize() const



ae::Vec2 struct

struct ae::Vec2
  : public VecT< Vec2 >

public float x

public float y

public float data

public union ae::Vec2::@0 @1

public Vec2() = default

public Vec2(const Vec2 &) = default

public inline explicit Vec2(float v)

public inline Vec2(float x,float y)

public inline explicit Vec2(const float * xy)

public inline explicit Vec2(struct Int2 i2)

public inline struct Int2 NearestCopy() const

public inline struct Int2 FloorCopy() const

public inline struct Int2 CeilCopy() const

public inline Vec2 RotateCopy(float rotation) const

public inline float GetAngle() const

public inline Vec2 DtSlerp(const Vec2 & end,float snappiness,float dt,float epsilon) const

public Vec2 Slerp(const Vec2 & end,float t,float epsilon) const



ae::Vec3 struct

struct ae::Vec3
  : public VecT< Vec3 >

public float x

public float y

public float z

public float data

public union ae::Vec3::@4 @5

public float pad

public Vec3() = default

public inline explicit Vec3(float v)

public inline Vec3(float x,float y,float z)

public inline explicit Vec3(const float * xyz)

public inline explicit Vec3(struct Int3 i3)

public inline Vec3(Vec2 xy,float z)

public inline explicit Vec3(Vec2 xy)

public inline explicit operator Vec2() const

public inline Vec2 GetXY() const

public inline Vec2 GetXZ() const

public inline Vec2 GetZY() const

public inline void SetXY(Vec2 xy)

public inline void SetXZ(Vec2 xz)

public inline void SetYZ(Vec2 yz)

public inline struct Int3 NearestCopy() const

public inline struct Int3 FloorCopy() const

public inline struct Int3 CeilCopy() const

public void AddRotationXY(float rotation)

public Vec3 AddRotationXYCopy(float rotation) const

public float GetAngleBetween(const Vec3 & v,float epsilon) const

public Vec3 RotateCopy(Vec3 axis,float angle) const

public inline Vec3 Lerp(const Vec3 & end,float t) const

public Vec3 DtSlerp(const Vec3 & end,float snappiness,float dt,float epsilon) const

public Vec3 Slerp(const Vec3 & end,float t,float epsilon) const

public inline Vec3 Cross(const Vec3 & v) const

public inline void ZeroAxis(Vec3 axis)

public inline void ZeroDirection(Vec3 direction)

public inline Vec3 ZeroAxisCopy(Vec3 axis) const

public inline Vec3 ZeroDirectionCopy(Vec3 direction) const



ae::Vec4 struct

struct ae::Vec4
  : public VecT< Vec4 >

public float x

public float y

public float z

public float w

public float data

public union ae::Vec4::@8 @9

public Vec4() = default

public Vec4(const Vec4 &) = default

public inline explicit Vec4(float f)

public inline explicit Vec4(float xyz,float w)

public inline Vec4(float x,float y,float z,float w)

public inline Vec4(Vec3 xyz,float w)

public inline Vec4(Vec2 xy,float z,float w)

public inline Vec4(Vec2 xy,Vec2 zw)

public inline explicit operator Vec2() const

public inline explicit operator Vec3() const

public inline Vec4(const float * xyz,float w)

public inline explicit Vec4(const float * xyzw)

public inline Vec2 GetXY() const

public inline Vec2 GetZW() const

public inline Vec3 GetXYZ() const



ae::IntT struct

public IntT() = default

public IntT(bool) = delete

public bool operator==(const T & v) const

public bool operator!=(const T & v) const

public int32_t operator[](uint32_t idx) const

public int32_t & operator[](uint32_t idx)

public T operator-() const

public T operator+(const T & v) const

public T operator-(const T & v) const

public T operator*(const T & v) const

public T operator/(const T & v) const

public void operator+=(const T & v)

public void operator-=(const T & v)

public void operator*=(const T & v)

public void operator/=(const T & v)

public T operator*(int32_t s) const

public T operator/(int32_t s) const

public void operator*=(int32_t s)

public void operator/=(int32_t s)



ae::Int2 struct

struct ae::Int2
  : public ae::IntT< Int2 >

public int32_t x

public int32_t y

public int32_t data

public union ae::Int2::@16 @17

public Int2() = default

public Int2(const Int2 &) = default

public inline explicit Int2(int32_t _v)

public inline explicit Int2(const struct Int3 & v)

public inline Int2(int32_t _x,int32_t _y)



ae::Int3 struct

struct ae::Int3
  : public ae::IntT< Int3 >

public int32_t x

public int32_t y

public int32_t z

public int32_t data

public union ae::Int3::@20 @21

public int32_t pad

public Int3() = default

public Int3(const Int3 &) = default

public inline explicit Int3(int32_t _v)

public inline Int3(int32_t _x,int32_t _y,int32_t _z)

public inline Int3(Int2 xy,int32_t _z)

public inline Int3(const int32_t(&) v)

public inline Int3(const int32_t(&) v)

public inline explicit Int3(int32_t *& v)

public inline explicit Int3(const int32_t *& v)

public inline Int2 GetXY() const