|
coastline 0.0.4
|
The vector and matrix arithmetic of the game, its arctangent and power, the triangle and segment tests, and its random numbers. More...
#include "common/types.h"

Go to the source code of this file.
Classes | |
| struct | Vec3f |
| A point or direction in space. More... | |
| struct | Vec2f |
| A point or direction in a plane. More... | |
Functions | |
| 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 series for the rest. | |
| void | Vec3fCross (Vec3f *out, Vec3f *a, Vec3f *b) |
| Take the cross product of two vectors. | |
| f32 | Vec3fDot (const Vec3f *a, const Vec3f *b) |
| Take the dot product of two vectors. | |
| void | Vec3fNegate (Vec3f *out, Vec3f *v) |
| Negate a vector. | |
| void | NegateVectorInPlace (Vec3f *v) |
| Negate a vector in place. | |
| void | Vec2fMul (Vec2f *out, Vec2f *a, Vec2f *b) |
| Multiply two vectors component by component. | |
| void | Vec2fScale (Vec2f *out, Vec2f *v, f32 scale) |
| Multiply a vector by a number. | |
| void | Vec3fComponentProduct (Vec3f *out, Vec3f *a, Vec3f *b) |
| Multiply two vectors component by component. | |
| void | Vec3fScale (Vec3f *out, Vec3f *v, f32 scale) |
| Multiply a vector by a number. | |
| void | Vec3fScaleInPlace (Vec3f *v, f32 scale) |
| Multiply a vector by a number in place. | |
| void | Vec3fScaleByInverse (Vec3f *out, Vec3f *v, f32 divisor) |
| Multiply a vector by the reciprocal of a number. | |
| void | Vec3fDivideInPlace (Vec3f *v, f32 divisor) |
| Divide a vector by a number in place. | |
| void | Vec3fCopy (Vec3f *out, Vec3f *v) |
| Copy a vector. | |
| void | Vec3fDirection (Vec3f *out, Vec3f *from, Vec3f *to) |
| The unit vector from one point towards another, or (0, 0, 1) when they coincide. | |
| void | Vec3fNormalizeSafe (Vec3f *out, Vec3f *v) |
| The unit vector along a vector, or (0, 0, 1) for the zero vector. | |
| void | Vec3fNormalize (Vec3f *v) |
| Make a vector a unit vector, or (0, 0, 1) if it is the zero vector. | |
| void | Vec3fSubtract (Vec3f *out, const Vec3f *a, const Vec3f *b) |
| Subtract one vector from another. | |
| void | Vec3fSubtractInPlace (Vec3f *v, Vec3f *b) |
| Subtract one vector from another in place. | |
| void | Vec2fAdd (Vec2f *out, Vec2f *a, Vec2f *b) |
| Add two vectors. | |
| void | Vec3fAdd (Vec3f *out, Vec3f *a, Vec3f *b) |
| Add two vectors. | |
| void | Vec3fAddInPlace (Vec3f *v, Vec3f *b) |
| Add one vector to another in place. | |
| 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 | Vec3fMulAdd (Vec3f *out, Vec3f *a, Vec3f *b, f32 scale) |
| Add a scaled vector to another. | |
| void | Vec3fMulAddInPlace (Vec3f *v, Vec3f *b, f32 scale) |
| Add a scaled vector to another in place. | |
| void | Vec3fMidpoint (Vec3f *out, Vec3f *a, Vec3f *b) |
| The point halfway between two points. | |
| void | Vec3fClear (Vec3f *v) |
| Set a vector to zero. | |
| f32 | Vec2fDistance (Vec2f *a, Vec2f *b) |
| The distance between two points of the plane. | |
| f32 | Vec3fDistance (Vec3f *a, Vec3f *b) |
| The distance between two points. | |
| f32 | Vec3fDistanceSquared (Vec3f *a, Vec3f *b) |
| The square of the distance between two points. | |
| f32 | Vec3fLength (Vec3f *v) |
| The length of a vector. | |
| f32 | Vec2fLength (Vec2f *v) |
| The length of a vector of the plane. | |
| 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 | Mtx4x4ProjectPoint (Vec3f *out, Vec3f *in, f32 m[4][4]) |
| Transform a point by a matrix and divide by w. | |
| void | Vec3fTransformByMatrix (f32 out[4], const Vec3f *in, f32 m[4][4]) |
| Transform a point by a matrix into four components. | |
| 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 | Mtx4x4TransformNoTranslation (Vec3f *out, Vec3f *in, f32 m[4][4]) |
| Transform a direction by a matrix without its translation, and divide by w. | |
| void | Mtx3x3TransformVec (Vec3f *out, Vec3f *in, f32 m[4][4]) |
| Transform a direction by the 3 by 3 part of a matrix. | |
| void | Mtx4x4Multiply (f32 out[4][4], f32 a[4][4], f32 b[4][4]) |
| Multiply two matrices. | |
| void | Mtx4fTranspose (f32 out[4][4], f32 in[4][4]) |
| Transpose a matrix but its diagonal, which is copied unchanged into the result. | |
| void | CopyMatrix4x4 (f32 out[4][4], f32 in[4][4]) |
| Copy a matrix. | |
| s32 | MtxInvert4x4 (f32 out[4][4], f32 in[4][4]) |
| Invert an affine matrix. | |
| void | FinishFrameMatrix (f32 m[4][4]) |
| Set the last column of a matrix to that of an affine transform: 0, 0, 0 and 1. | |
| 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 sine. | |
| 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. | |
| s32 | IsPointInsideTriangle (Vec3f *point, Vec3f *v0, Vec3f *v1, Vec3f *v2, Vec3f *normal, f32 tolerance) |
| PointInTriangle3D() with a tolerance for each edge. | |
| s32 | TestLineSegmentIntersection (Vec2f *p1, Vec2f *p2, Vec2f *q1, Vec2f *q2) |
| Whether two segments of the plane meet. | |
| 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 | SetRngSeed (u32 seed) |
| Set the seed of the random numbers. | |
| u32 | AdvanceRng (void) |
| Advance the random numbers by the multiplier 16807 and retain 27 bits. | |
Variables | |
| u32 | g_dwRandomSeed |
| The seed used by the game's pseudorandom number generator. | |
The vector and matrix arithmetic of the game, its arctangent and power, the triangle and segment tests, and its random numbers.
Raise a number to a power: by multiplication for the whole part of the exponent and by the binomial series for the rest.
| base | The number raised. |
| exponent | The power, at least 0. |
Take the cross product of two vectors.
| out | The vector that receives the cross product of a and b. |
| a | The first vector. |
| b | The second vector. |
Take the dot product of two vectors.
| a | The first vector. |
| b | The second vector. |
Negate a vector.
| out | The vector that receives -v. |
| v | The vector negated. |
| void NegateVectorInPlace | ( | Vec3f * | v | ) |
Negate a vector in place.
| v | The vector negated. |
Multiply two vectors component by component.
| out | The vector that receives the product. |
| a | The first vector. |
| b | The second vector. |
Multiply a vector by a number.
| out | The vector that receives v * scale. |
| v | The vector scaled. |
| scale | The factor. |
Multiply two vectors component by component.
| out | The vector that receives the product. |
| a | The first vector. |
| b | The second vector. |
Multiply a vector by a number.
| out | The vector that receives v * scale. |
| v | The vector scaled. |
| scale | The factor. |
Multiply a vector by a number in place.
| v | The vector scaled. |
| scale | The factor. |
Multiply a vector by the reciprocal of a number.
| out | The vector that receives v / divisor. |
| v | The vector divided. |
| divisor | The number the vector is divided by. |
Divide a vector by a number in place.
| v | The vector divided. |
| divisor | The number the vector is divided by. |
Copy a vector.
| out | The vector that receives the copy. |
| v | The vector copied. |
The unit vector from one point towards another, or (0, 0, 1) when they coincide.
| out | The vector that receives the direction. |
| from | The point the direction starts at. |
| to | The point the direction runs towards. |
The unit vector along a vector, or (0, 0, 1) for the zero vector.
| out | The vector that receives the unit vector. |
| v | The vector normalised. |
| void Vec3fNormalize | ( | Vec3f * | v | ) |
Make a vector a unit vector, or (0, 0, 1) if it is the zero vector.
Windows also uses that direction when the length is unordered.
| v | The vector normalised in place. |
Subtract one vector from another.
| out | The vector that receives a - b. |
| a | The vector subtracted from. |
| b | The vector subtracted. |
Subtract one vector from another in place.
| v | The vector subtracted from, which receives v - b. |
| b | The vector subtracted. |
Add two vectors.
| out | The vector that receives a + b. |
| a | The first vector. |
| b | The second vector. |
Add two vectors.
| out | The vector that receives a + b. |
| a | The first vector. |
| b | The second vector. |
Add one vector to another in place.
| v | The vector added to, which receives v + b. |
| b | The vector added. |
The point a share of the way from b to a: b + (a - b) * t.
| out | The vector that receives the point. |
| a | The point reached when t is 1. |
| b | The point reached when t is 0. |
| t | The share of the way from b to a. |
Add a scaled vector to another.
| out | The vector that receives a + b * scale. |
| a | The vector added to. |
| b | The vector scaled and added. |
| scale | The factor for b. |
Add a scaled vector to another in place.
| v | The vector added to, which receives v + b * scale. |
| b | The vector scaled and added. |
| scale | The factor for b. |
The point halfway between two points.
| out | The vector that receives the midpoint. |
| a | The first point. |
| b | The second point. |
| void Vec3fClear | ( | Vec3f * | v | ) |
Set a vector to zero.
| v | The vector cleared. |
The distance between two points of the plane.
| a | The first point. |
| b | The second point. |
The distance between two points.
| a | The first point. |
| b | The second point. |
The square of the distance between two points.
| a | The first point. |
| b | The second point. |
The length of a vector.
| v | The vector measured. |
The length of a vector of the plane.
| v | The vector measured. |
Rotate a vector by an angle about a unit axis, clockwise as seen from the tip of the axis.
| v | The vector rotated in place. |
| angle | The angle of the rotation, in radians. |
| axis | The unit axis of the rotation. |
Transform a point by a matrix and divide by w.
| out | The vector that receives the transformed point. |
| in | The point transformed. |
| m | The matrix, applied to a row vector with its translation in the last row. |
Transform a point by a matrix into four components.
| out | The x, y, z, and w of the transformed point. |
| in | The point transformed. |
| m | The matrix, applied to a row vector with its translation in the last row. |
Transform a point of short integers by a matrix into four components.
| out | The x, y, z, and w of the transformed point. |
| in | The x, y, and z of the point transformed. |
| m | The matrix, applied to a row vector with its translation in the last row. |
Transform a point by a matrix, divide by w, and retain x and y.
| out | The vector that receives the x and y of the transformed point. |
| in | The point transformed. |
| m | The matrix, applied to a row vector with its translation in the last row. |
Transform a direction by a matrix without its translation, and divide by w.
| out | The vector that receives the transformed direction. |
| in | The direction transformed. |
| m | The matrix, applied to a row vector. |
Transform a direction by the 3 by 3 part of a matrix.
| out | The vector that receives the transformed direction. |
| in | The direction transformed. |
| m | The matrix, applied to a row vector. |
Multiply two matrices.
The result may replace either of them.
| out | The matrix that receives a * b. |
| a | The matrix on the left. |
| b | The matrix on the right. |
Transpose a matrix but its diagonal, which is copied unchanged into the result.
| out | The matrix that receives the transpose. |
| in | The matrix transposed. |
Copy a matrix.
| out | The matrix that receives the copy. |
| in | The matrix copied. |
Invert an affine matrix.
On the N64 a singular matrix is reported on the debug display and out is not written. On the PC a singular matrix inverts to the identity.
| out | The matrix that receives the inverse. |
| in | The matrix inverted. |
| void FinishFrameMatrix | ( | f32 | m[4][4] | ) |
Set the last column of a matrix to that of an affine transform: 0, 0, 0 and 1.
| m | The matrix completed in place. |
The angle of a point counterclockwise from the x axis, from 0 to two pi, found by a search of the sine.
Unlike atan2() of the C library, it takes x first.
| x | The x of the point. |
| y | The y of the point. |
Whether a point lies within a triangle, on the side of each edge the normal gives.
| point | The point tested. |
| v0 | The first corner of the triangle. |
| v1 | The second corner of the triangle. |
| v2 | The third corner of the triangle. |
| normal | The normal of the triangle. |
| s32 IsPointInsideTriangle | ( | Vec3f * | point, |
| Vec3f * | v0, | ||
| Vec3f * | v1, | ||
| Vec3f * | v2, | ||
| Vec3f * | normal, | ||
| f32 | tolerance ) |
PointInTriangle3D() with a tolerance for each edge.
| point | The point tested. |
| v0 | The first corner of the triangle. |
| v1 | The second corner of the triangle. |
| v2 | The third corner of the triangle. |
| normal | The normal of the triangle. |
| tolerance | The least value of the test against each edge for the point to pass it. |
Whether two segments of the plane meet.
| p1 | The first end of the first segment. |
| p2 | The second end of the first segment. |
| q1 | The first end of the second segment. |
| q2 | The second end of the second segment. |
Whether two points lie across the line through two others, seen from above: only x and y are read.
| a | The first point of the line. |
| b | The second point of the line. |
| p | The first point tested. |
| q | The second point tested. |
| void SetRngSeed | ( | u32 | seed | ) |
Set the seed of the random numbers.
| seed | The new seed. |
| u32 AdvanceRng | ( | void | ) |
Advance the random numbers by the multiplier 16807 and retain 27 bits.
|
extern |
The seed used by the game's pseudorandom number generator.