1#ifndef COASTLINE_VECMATH_H
2#define COASTLINE_VECMATH_H
690#if defined(_MSC_VER) && !defined(_WIN64)
825long double Vec3dLengthSquared(Vec3d *v);
835long double Vec3dLength(Vec3d *v);
845Vec3d *Vec3dNormalize(Vec3d *v);
856long double Vec3dDot(Vec3d *a, Vec3d *b);
867void Vec3dCross(Vec3d *a, Vec3d *b, Vec3d *out);
A point or direction in a plane.
Definition vecmath.h:24
f32 x
Definition vecmath.h:25
f32 y
Definition vecmath.h:26
A point or direction in space.
Definition vecmath.h:17
f32 z
Definition vecmath.h:20
f32 x
Definition vecmath.h:18
f32 y
Definition vecmath.h:19
The integer and floating-point types of the console, for headers shared with Windows.
unsigned int u32
Definition ultratypes.h:20
short s16
Definition ultratypes.h:24
float f32
Definition ultratypes.h:38
double f64
Definition ultratypes.h:39
int s32
Definition ultratypes.h:25
void Vec3fCopy(Vec3f *out, Vec3f *v)
Copy a vector.
void Vec3fScale(Vec3f *out, Vec3f *v, f32 scale)
Multiply a vector by a number.
u32 AdvanceRng(void)
Advance the random numbers by the multiplier 16807 and retain 27 bits.
void Mtx4fTranspose(f32 out[4][4], f32 in[4][4])
Transpose a matrix but its diagonal, which is copied unchanged into the result.
s32 IsPointInsideTriangle(Vec3f *point, Vec3f *v0, Vec3f *v1, Vec3f *v2, Vec3f *normal, f32 tolerance)
PointInTriangle3D() with a tolerance for each edge.
void Vec3fCross(Vec3f *out, Vec3f *a, Vec3f *b)
Take the cross product of two vectors.
void Vec3fLerp(Vec3f *out, Vec3f *a, Vec3f *b, f32 t)
The point a share of the way from b to a: b + (a - b) * t.
void Vec3fSubtract(Vec3f *out, const Vec3f *a, const Vec3f *b)
Subtract one vector from another.
void Vec3fDivideInPlace(Vec3f *v, f32 divisor)
Divide a vector by a number in place.
void Vec3fClear(Vec3f *v)
Set a vector to zero.
void Vec2fScale(Vec2f *out, Vec2f *v, f32 scale)
Multiply a vector by a number.
void FinishFrameMatrix(f32 m[4][4])
Set the last column of a matrix to that of an affine transform: 0, 0, 0 and 1.
void Mtx3x3TransformVec(Vec3f *out, Vec3f *in, f32 m[4][4])
Transform a direction by the 3 by 3 part of a matrix.
void Vec3fMidpoint(Vec3f *out, Vec3f *a, Vec3f *b)
The point halfway between two points.
void Vec3fNormalizeSafe(Vec3f *out, Vec3f *v)
The unit vector along a vector, or (0, 0, 1) for the zero vector.
void Vec3fRotateAroundAxis(Vec3f *v, f32 angle, Vec3f *axis)
Rotate a vector by an angle about a unit axis, clockwise as seen from the tip of the axis.
void Mtx4x4Multiply(f32 out[4][4], f32 a[4][4], f32 b[4][4])
Multiply two matrices.
s32 TestLineSegmentIntersection(Vec2f *p1, Vec2f *p2, Vec2f *q1, Vec2f *q2)
Whether two segments of the plane meet.
void Vec3fNegate(Vec3f *out, Vec3f *v)
Negate a vector.
u32 g_dwRandomSeed
The seed used by the game's pseudorandom number generator.
void Vec3fAddInPlace(Vec3f *v, Vec3f *b)
Add one vector to another in place.
s32 MtxInvert4x4(f32 out[4][4], f32 in[4][4])
Invert an affine matrix.
void Vec3fScaleByInverse(Vec3f *out, Vec3f *v, f32 divisor)
Multiply a vector by the reciprocal of a number.
void Vec3fAdd(Vec3f *out, Vec3f *a, Vec3f *b)
Add two vectors.
f32 Powf(f32 base, f32 exponent)
Raise a number to a power: by multiplication for the whole part of the exponent and by the binomial s...
f32 Atan2f(f32 x, f32 y)
The angle of a point counterclockwise from the x axis, from 0 to two pi, found by a search of the sin...
f32 Vec2fLength(Vec2f *v)
The length of a vector of the plane.
void Vec3sTransformToVec4f(f32 out[4], s16 in[3], f32 m[4][4])
Transform a point of short integers by a matrix into four components.
void ProjectVec3fToScreen(Vec2f *out, Vec3f *in, f32 m[4][4])
Transform a point by a matrix, divide by w, and retain x and y.
void Vec3fMulAddInPlace(Vec3f *v, Vec3f *b, f32 scale)
Add a scaled vector to another in place.
f32 Vec3fDistance(Vec3f *a, Vec3f *b)
The distance between two points.
void Vec3fNormalize(Vec3f *v)
Make a vector a unit vector, or (0, 0, 1) if it is the zero vector.
s32 PointInTriangle3D(Vec3f *point, Vec3f *v0, Vec3f *v1, Vec3f *v2, Vec3f *normal)
Whether a point lies within a triangle, on the side of each edge the normal gives.
void SetRngSeed(u32 seed)
Set the seed of the random numbers.
void Mtx4x4ProjectPoint(Vec3f *out, Vec3f *in, f32 m[4][4])
Transform a point by a matrix and divide by w.
f32 Vec2fDistance(Vec2f *a, Vec2f *b)
The distance between two points of the plane.
f32 Vec3fDot(const Vec3f *a, const Vec3f *b)
Take the dot product of two vectors.
void Vec3fSubtractInPlace(Vec3f *v, Vec3f *b)
Subtract one vector from another in place.
void Vec2fMul(Vec2f *out, Vec2f *a, Vec2f *b)
Multiply two vectors component by component.
void Vec3fTransformByMatrix(f32 out[4], const Vec3f *in, f32 m[4][4])
Transform a point by a matrix into four components.
void CopyMatrix4x4(f32 out[4][4], f32 in[4][4])
Copy a matrix.
f32 Vec3fDistanceSquared(Vec3f *a, Vec3f *b)
The square of the distance between two points.
void Mtx4x4TransformNoTranslation(Vec3f *out, Vec3f *in, f32 m[4][4])
Transform a direction by a matrix without its translation, and divide by w.
f32 Vec3fLength(Vec3f *v)
The length of a vector.
void Vec3fMulAdd(Vec3f *out, Vec3f *a, Vec3f *b, f32 scale)
Add a scaled vector to another.
void Vec2fAdd(Vec2f *out, Vec2f *a, Vec2f *b)
Add two vectors.
void Vec3fComponentProduct(Vec3f *out, Vec3f *a, Vec3f *b)
Multiply two vectors component by component.
void NegateVectorInPlace(Vec3f *v)
Negate a vector in place.
s32 SegmentCrossesLine2D(const Vec3f *a, const Vec3f *b, const Vec3f *p, const Vec3f *q)
Whether two points lie across the line through two others, seen from above: only x and y are read.
void Vec3fDirection(Vec3f *out, Vec3f *from, Vec3f *to)
The unit vector from one point towards another, or (0, 0, 1) when they coincide.
void Vec3fScaleInPlace(Vec3f *v, f32 scale)
Multiply a vector by a number in place.