@phalanx-engine/math 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,124 @@
1
+ # Phalanx Math
2
+
3
+ Deterministic fixed-point math library for Phalanx Engine. Ensures identical calculations across all platforms and hardware for lockstep multiplayer games.
4
+
5
+ ## Overview
6
+
7
+ This library wraps `@hastom/fixed-point` to provide a Unity/Quantum-style API for deterministic arithmetic. All clients using the same operations will produce identical results, preventing desync in lockstep multiplayer games.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ pnpm add @phalanx-engine/math
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```typescript
18
+ import { FP, FPVector2, FPVector3 } from '@phalanx-engine/math';
19
+
20
+ // Create fixed-point numbers
21
+ const speed = FP.FromFloat(5.5);
22
+ const deltaTime = FP.FromFloat(0.016);
23
+
24
+ // Arithmetic operations
25
+ const distance = FP.Mul(speed, deltaTime);
26
+
27
+ // 2D vectors
28
+ const velocity = FPVector2.FromFloat(3, 4);
29
+ const length = FPVector2.Magnitude(velocity); // 5
30
+
31
+ // 3D positions (for game entities)
32
+ const position = FPVector3.FromFloat(10, 0, 20);
33
+ const target = FPVector3.FromFloat(15, 0, 25);
34
+ const dist = FPVector3.Distance(position, target);
35
+
36
+ // Convert back to numbers for rendering
37
+ console.log(FP.ToFloat(dist));
38
+ ```
39
+
40
+ ## API
41
+
42
+ ### FP
43
+
44
+ Unified namespace for fixed-point operations (Unity/Quantum style):
45
+
46
+ #### Creation
47
+ - `FP.FromFloat(value: number)` - Create from JavaScript number
48
+ - `FP.FromString(value: string)` - Create from string representation
49
+ - `FP.FromInt(value: number | bigint)` - Create from integer
50
+ - `FP.ToFloat(fp: FixedPoint)` - Convert back to JavaScript number
51
+
52
+ #### Constants
53
+ - `FP._0`, `FP._1` - Zero and One (Quantum naming)
54
+ - `FP.Pi`, `FP.Pi2`, `FP.PiOver2` - Pi constants
55
+
56
+ #### Arithmetic
57
+ - `FP.Add`, `FP.Sub`, `FP.Mul`, `FP.Div`, `FP.Neg` - Basic arithmetic
58
+
59
+ #### Math Functions
60
+ - `FP.Sqrt`, `FP.Abs` - Unary operations
61
+ - `FP.Floor`, `FP.Ceil`, `FP.Round` - Rounding
62
+ - `FP.Min`, `FP.Max`, `FP.Clamp` - Range operations
63
+ - `FP.Lerp` - Linear interpolation
64
+
65
+ #### Comparison
66
+ - `FP.Eq`, `FP.Lt`, `FP.Lte`, `FP.Gt`, `FP.Gte` - Comparisons
67
+
68
+ #### Trigonometry
69
+ - `FP.Sin`, `FP.Cos`, `FP.Atan2` - Deterministic approximations
70
+
71
+ ### FPVector2
72
+
73
+ 2D vector operations for game logic:
74
+
75
+ #### Creation
76
+ - `FPVector2.Create(x, y)` - Create from FixedPoint values
77
+ - `FPVector2.FromFloat(x, y)` - Create from numbers
78
+
79
+ #### Constants
80
+ - `FPVector2.Zero`, `FPVector2.One` - Common vectors
81
+ - `FPVector2.Up`, `FPVector2.Right` - Direction vectors
82
+
83
+ #### Operations
84
+ - `FPVector2.Add`, `FPVector2.Sub`, `FPVector2.Scale` - Vector arithmetic
85
+ - `FPVector2.Magnitude`, `FPVector2.SqrMagnitude` - Length (Unity naming)
86
+ - `FPVector2.Normalize`, `FPVector2.Dot` - Geometric operations
87
+ - `FPVector2.Distance`, `FPVector2.SqrDistance` - Distance calculations
88
+ - `FPVector2.Lerp` - Interpolation
89
+ - `FPVector2.ToFloat` - Convert for rendering
90
+
91
+ ### FPVector3
92
+
93
+ 3D vector operations for entity positions:
94
+
95
+ #### Creation
96
+ - `FPVector3.Create(x, y, z)` - Create from FixedPoint values
97
+ - `FPVector3.FromFloat(x, y, z)` - Create from numbers
98
+
99
+ #### Constants
100
+ - `FPVector3.Zero`, `FPVector3.One` - Common vectors
101
+ - `FPVector3.Up`, `FPVector3.Right`, `FPVector3.Forward` - Direction vectors
102
+
103
+ #### Operations
104
+ - `FPVector3.Add`, `FPVector3.Sub`, `FPVector3.Scale` - Vector arithmetic
105
+ - `FPVector3.Magnitude`, `FPVector3.SqrMagnitude` - Length (Unity naming)
106
+ - `FPVector3.Normalize`, `FPVector3.Dot`, `FPVector3.Cross` - Geometric operations
107
+ - `FPVector3.Distance`, `FPVector3.SqrDistance` - Distance calculations
108
+ - `FPVector3.Lerp` - Interpolation
109
+ - `FPVector3.ToFloat` - Convert for rendering
110
+
111
+ ## Why Fixed-Point?
112
+
113
+ JavaScript's `Number` type uses IEEE 754 floating-point, which can produce slightly different results on different platforms/hardware. In lockstep multiplayer, even tiny differences compound over time, causing desync.
114
+
115
+ Fixed-point math uses integer arithmetic with a fixed decimal scale, guaranteeing identical results everywhere.
116
+
117
+ ## Performance Considerations
118
+
119
+ Fixed-point operations using BigInt are slower than native floats. For most games, this overhead is negligible. If you encounter performance issues:
120
+
121
+ 1. Profile to confirm fixed-point math is the bottleneck
122
+ 2. Consider batching operations
123
+ 3. Only use fixed-point for deterministic simulation; use floats for visual-only calculations
124
+
@@ -0,0 +1,246 @@
1
+ /**
2
+ * Fixed-Point Math Module
3
+ *
4
+ * Provides deterministic fixed-point arithmetic for game calculations.
5
+ * All clients using the same operations will produce identical results.
6
+ *
7
+ * This module wraps @hastom/fixed-point library to provide a Unity/Quantum-style API.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { FP, FPVector3 } from '@phalanx-engine/math';
12
+ *
13
+ * const position = FPVector3.FromFloat(10.5, 0, 20.3);
14
+ * const target = FPVector3.FromFloat(5.0, 0, 10.0);
15
+ *
16
+ * const distance = FPVector3.Distance(position, target);
17
+ *
18
+ * // Convert back to number for display
19
+ * console.log(FP.ToFloat(distance));
20
+ * ```
21
+ */
22
+ import { FixedPoint } from '@hastom/fixed-point';
23
+ export { FixedPoint };
24
+ /**
25
+ * FP - Fixed-point number creation, conversion, and math utilities
26
+ * Quantum-style unified API for all fixed-point operations
27
+ */
28
+ export declare const FP: {
29
+ /**
30
+ * Create a fixed-point number from a JavaScript number
31
+ *
32
+ * WARNING: This uses toFixed(15) to ensure deterministic conversion across
33
+ * different JavaScript engines (V8/Chrome, JSC/Safari, SpiderMonkey/Firefox).
34
+ * Native toString() can produce different results for the same float.
35
+ *
36
+ * @param value - Number to convert
37
+ * @param precision - Decimal precision (default: 18)
38
+ */
39
+ FromFloat: (value: number, precision?: number) => FixedPoint;
40
+ /**
41
+ * Create a fixed-point number from a string representation
42
+ * @param value - String representation (e.g., "10.5")
43
+ * @param precision - Decimal precision (default: 18)
44
+ */
45
+ FromString: (value: string, precision?: number) => FixedPoint;
46
+ /**
47
+ * Create a fixed-point number from an integer
48
+ * @param value - Integer value
49
+ * @param precision - Decimal precision (default: 18)
50
+ */
51
+ FromInt: (value: number | bigint, precision?: number) => FixedPoint;
52
+ /**
53
+ * Convert a fixed-point number back to a JavaScript number
54
+ */
55
+ ToFloat: (fp: FixedPoint) => number;
56
+ /**
57
+ * Get the raw bigint base value from a FixedPoint
58
+ * Used for SoA storage in BigInt64Array
59
+ *
60
+ * Note: This requires storing the precision separately or assuming
61
+ * all values use DEFAULT_PRECISION (18).
62
+ */
63
+ ToRaw: (fp: FixedPoint) => bigint;
64
+ /**
65
+ * Create a FixedPoint from a raw bigint base value
66
+ * Used for reading from SoA storage (BigInt64Array)
67
+ *
68
+ * @param raw - The raw bigint base value
69
+ * @param precision - The precision (default: 18)
70
+ */
71
+ FromRaw: (raw: bigint, precision?: number) => FixedPoint;
72
+ /** Zero constant */
73
+ _0: FixedPoint;
74
+ /** One constant */
75
+ _1: FixedPoint;
76
+ /** Pi constant */
77
+ Pi: FixedPoint;
78
+ /** 2*Pi constant (Quantum naming) */
79
+ Pi2: FixedPoint;
80
+ /** Pi/2 constant (Quantum naming) */
81
+ PiOver2: FixedPoint;
82
+ /** Add two fixed-point numbers */
83
+ Add: (a: FixedPoint, b: FixedPoint) => FixedPoint;
84
+ /** Subtract two fixed-point numbers */
85
+ Sub: (a: FixedPoint, b: FixedPoint) => FixedPoint;
86
+ /** Multiply two fixed-point numbers */
87
+ Mul: (a: FixedPoint, b: FixedPoint) => FixedPoint;
88
+ /** Divide two fixed-point numbers */
89
+ Div: (a: FixedPoint, b: FixedPoint) => FixedPoint;
90
+ /** Negate a fixed-point number */
91
+ Neg: (a: FixedPoint) => FixedPoint;
92
+ /** Square root of a fixed-point number */
93
+ Sqrt: (a: FixedPoint) => FixedPoint;
94
+ /** Absolute value of a fixed-point number */
95
+ Abs: (a: FixedPoint) => FixedPoint;
96
+ /** Floor of a fixed-point number */
97
+ Floor: (a: FixedPoint) => FixedPoint;
98
+ /** Ceiling of a fixed-point number */
99
+ Ceil: (a: FixedPoint) => FixedPoint;
100
+ /** Round a fixed-point number */
101
+ Round: (a: FixedPoint) => FixedPoint;
102
+ /** Minimum of two fixed-point numbers */
103
+ Min: (a: FixedPoint, b: FixedPoint) => FixedPoint;
104
+ /** Maximum of two fixed-point numbers */
105
+ Max: (a: FixedPoint, b: FixedPoint) => FixedPoint;
106
+ /** Check if two fixed-point numbers are equal */
107
+ Eq: (a: FixedPoint, b: FixedPoint) => boolean;
108
+ /** Check if first is less than second */
109
+ Lt: (a: FixedPoint, b: FixedPoint) => boolean;
110
+ /** Check if first is less than or equal to second */
111
+ Lte: (a: FixedPoint, b: FixedPoint) => boolean;
112
+ /** Check if first is greater than second */
113
+ Gt: (a: FixedPoint, b: FixedPoint) => boolean;
114
+ /** Check if first is greater than or equal to second */
115
+ Gte: (a: FixedPoint, b: FixedPoint) => boolean;
116
+ /**
117
+ * Linear interpolation between two values
118
+ * @param a - Start value
119
+ * @param b - End value
120
+ * @param t - Interpolation factor (0-1)
121
+ */
122
+ Lerp: (a: FixedPoint, b: FixedPoint, t: FixedPoint) => FixedPoint;
123
+ /** Clamp a value between min and max */
124
+ Clamp: (value: FixedPoint, min: FixedPoint, max: FixedPoint) => FixedPoint;
125
+ /**
126
+ * Sine approximation using Taylor series (deterministic)
127
+ * Note: Input should be in radians
128
+ */
129
+ Sin: (x: FixedPoint) => FixedPoint;
130
+ /**
131
+ * Cosine approximation using Taylor series (deterministic)
132
+ * Note: Input should be in radians
133
+ */
134
+ Cos: (x: FixedPoint) => FixedPoint;
135
+ /**
136
+ * Approximate atan2 (deterministic)
137
+ * Returns angle in radians
138
+ */
139
+ Atan2: (y: FixedPoint, x: FixedPoint) => FixedPoint;
140
+ };
141
+ /**
142
+ * Fixed-point 2D vector interface
143
+ */
144
+ export interface FPVector2 {
145
+ x: FixedPoint;
146
+ y: FixedPoint;
147
+ }
148
+ /**
149
+ * FPVector2 - Fixed-point 2D vector utilities (Unity/Quantum style)
150
+ */
151
+ export declare const FPVector2: {
152
+ /** Create a new vector from FixedPoint values */
153
+ Create: (x: FixedPoint, y: FixedPoint) => FPVector2;
154
+ /** Create a vector from float numbers */
155
+ FromFloat: (x: number, y: number) => FPVector2;
156
+ /** Zero vector */
157
+ Zero: FPVector2;
158
+ /** One vector (1, 1) */
159
+ One: FPVector2;
160
+ /** Up direction (0, 1) - Unity convention */
161
+ Up: FPVector2;
162
+ /** Right direction (1, 0) - Unity convention */
163
+ Right: FPVector2;
164
+ /** Add two vectors */
165
+ Add: (a: FPVector2, b: FPVector2) => FPVector2;
166
+ /** Subtract two vectors */
167
+ Sub: (a: FPVector2, b: FPVector2) => FPVector2;
168
+ /** Scale a vector by a scalar */
169
+ Scale: (v: FPVector2, s: FixedPoint) => FPVector2;
170
+ /** Get the magnitude (length) of a vector - Unity naming */
171
+ Magnitude: (v: FPVector2) => FixedPoint;
172
+ /** Get the squared magnitude of a vector (faster than Magnitude) - Unity naming */
173
+ SqrMagnitude: (v: FPVector2) => FixedPoint;
174
+ /** Normalize a vector (returns new vector) */
175
+ Normalize: (v: FPVector2) => FPVector2;
176
+ /** Dot product of two vectors */
177
+ Dot: (a: FPVector2, b: FPVector2) => FixedPoint;
178
+ /** Distance between two vectors */
179
+ Distance: (a: FPVector2, b: FPVector2) => FixedPoint;
180
+ /** Squared distance between two vectors (faster than Distance) */
181
+ SqrDistance: (a: FPVector2, b: FPVector2) => FixedPoint;
182
+ /** Linear interpolation between two vectors */
183
+ Lerp: (a: FPVector2, b: FPVector2, t: FixedPoint) => FPVector2;
184
+ /** Convert to plain object with float values (for display/serialization) */
185
+ ToFloat: (v: FPVector2) => {
186
+ x: number;
187
+ y: number;
188
+ };
189
+ };
190
+ /**
191
+ * Fixed-point 3D vector interface
192
+ * Renamed from FPPosition for clarity (Quantum uses FPVector3)
193
+ */
194
+ export interface FPVector3 {
195
+ x: FixedPoint;
196
+ y: FixedPoint;
197
+ z: FixedPoint;
198
+ }
199
+ /**
200
+ * FPVector3 - Fixed-point 3D vector utilities (Unity/Quantum style)
201
+ */
202
+ export declare const FPVector3: {
203
+ /** Create a new 3D vector from FixedPoint values */
204
+ Create: (x: FixedPoint, y: FixedPoint, z: FixedPoint) => FPVector3;
205
+ /** Create a 3D vector from float numbers */
206
+ FromFloat: (x: number, y: number, z: number) => FPVector3;
207
+ /** Zero vector */
208
+ Zero: FPVector3;
209
+ /** One vector (1, 1, 1) */
210
+ One: FPVector3;
211
+ /** Up direction (0, 1, 0) - Unity convention */
212
+ Up: FPVector3;
213
+ /** Right direction (1, 0, 0) - Unity convention */
214
+ Right: FPVector3;
215
+ /** Forward direction (0, 0, 1) - Unity convention */
216
+ Forward: FPVector3;
217
+ /** Add two 3D vectors */
218
+ Add: (a: FPVector3, b: FPVector3) => FPVector3;
219
+ /** Subtract two 3D vectors */
220
+ Sub: (a: FPVector3, b: FPVector3) => FPVector3;
221
+ /** Scale a 3D vector by a scalar */
222
+ Scale: (v: FPVector3, s: FixedPoint) => FPVector3;
223
+ /** Get the magnitude (length) of a 3D vector - Unity naming */
224
+ Magnitude: (v: FPVector3) => FixedPoint;
225
+ /** Get the squared magnitude of a 3D vector (faster than Magnitude) - Unity naming */
226
+ SqrMagnitude: (v: FPVector3) => FixedPoint;
227
+ /** Normalize a 3D vector (returns new vector) */
228
+ Normalize: (v: FPVector3) => FPVector3;
229
+ /** Dot product of two 3D vectors */
230
+ Dot: (a: FPVector3, b: FPVector3) => FixedPoint;
231
+ /** Cross product of two 3D vectors */
232
+ Cross: (a: FPVector3, b: FPVector3) => FPVector3;
233
+ /** Distance between two 3D vectors */
234
+ Distance: (a: FPVector3, b: FPVector3) => FixedPoint;
235
+ /** Squared distance between two 3D vectors (faster than Distance) */
236
+ SqrDistance: (a: FPVector3, b: FPVector3) => FixedPoint;
237
+ /** Linear interpolation between two 3D vectors */
238
+ Lerp: (a: FPVector3, b: FPVector3, t: FixedPoint) => FPVector3;
239
+ /** Convert to plain object with float values (for display/serialization) */
240
+ ToFloat: (v: FPVector3) => {
241
+ x: number;
242
+ y: number;
243
+ z: number;
244
+ };
245
+ };
246
+ //# sourceMappingURL=FixedMath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FixedMath.d.ts","sourceRoot":"","sources":["../src/FixedMath.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,UAAU,EAA4B,MAAM,qBAAqB,CAAC;AAG3E,OAAO,EAAE,UAAU,EAAE,CAAC;AAKtB;;;GAGG;AACH,eAAO,MAAM,EAAE;IAGb;;;;;;;;;OASG;uBACgB,MAAM,cAAa,MAAM,KAAuB,UAAU;IAO7E;;;;OAIG;wBAEM,MAAM,cACF,MAAM,KAChB,UAAU;IAIb;;;;OAIG;qBAEM,MAAM,GAAG,MAAM,cACX,MAAM,KAChB,UAAU;IAIb;;OAEG;kBACW,UAAU,KAAG,MAAM;IAIjC;;;;;;OAMG;gBACS,UAAU,KAAG,MAAM;IAI/B;;;;;;OAMG;mBACY,MAAM,cAAa,MAAM,KAAuB,UAAU;IAMzE,oBAAoB;;IAGpB,mBAAmB;;IAGnB,kBAAkB;;IAGlB,qCAAqC;;IAGrC,qCAAqC;;IAKrC,kCAAkC;aACzB,UAAU,KAAK,UAAU,KAAG,UAAU;IAE/C,uCAAuC;aAC9B,UAAU,KAAK,UAAU,KAAG,UAAU;IAE/C,uCAAuC;aAC9B,UA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ACzB,SAAS,KAAK,UAAU,KAAG,SAAS;IAM/C,+DAA+D;mBAChD,SAAS,KAAG,UAAU;IAIrC,sFAAsF;sBACpE,SAAS,KAAG,UAAU;IAIxC,iDAAiD;mBAClC,SAAS,KAAG,SAAS;IAYpC,oCAAoC;aAC3B,SAAS,KAAK,SAAS,KAAG,UAAU;IAI7C,sCAAsC;eAC3B,SAAS,KAAK,SAAS,KAAG,SAAS;IAM9C,sCAAsC;kBACxB,SAAS,KAAK,SAAS,KAAG,UAAU;IAOlD,qEAAqE;qBACpD,SAAS,KAAK,SAAS,KAAG,UAAU;IAOrD,kDAAkD;cACxC,SAAS,KAAK,SAAS,KAAK,UAAU,KAAG,SAAS;IAQ5D,4EAA4E;iBAC/D,SAAS,KAAG;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE;CAK7D,CAAC"}
@@ -0,0 +1,420 @@
1
+ /**
2
+ * Fixed-Point Math Module
3
+ *
4
+ * Provides deterministic fixed-point arithmetic for game calculations.
5
+ * All clients using the same operations will produce identical results.
6
+ *
7
+ * This module wraps @hastom/fixed-point library to provide a Unity/Quantum-style API.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { FP, FPVector3 } from '@phalanx-engine/math';
12
+ *
13
+ * const position = FPVector3.FromFloat(10.5, 0, 20.3);
14
+ * const target = FPVector3.FromFloat(5.0, 0, 10.0);
15
+ *
16
+ * const distance = FPVector3.Distance(position, target);
17
+ *
18
+ * // Convert back to number for display
19
+ * console.log(FP.ToFloat(distance));
20
+ * ```
21
+ */
22
+ import { FixedPoint, fpFromDecimal, fpFromInt } from '@hastom/fixed-point';
23
+ // Re-export FixedPoint class as the number type
24
+ export { FixedPoint };
25
+ /** Default precision for fixed-point operations (5 decimal places) */
26
+ const DEFAULT_PRECISION = 5;
27
+ /**
28
+ * FP - Fixed-point number creation, conversion, and math utilities
29
+ * Quantum-style unified API for all fixed-point operations
30
+ */
31
+ export const FP = {
32
+ // ============ Creation ============
33
+ /**
34
+ * Create a fixed-point number from a JavaScript number
35
+ *
36
+ * WARNING: This uses toFixed(15) to ensure deterministic conversion across
37
+ * different JavaScript engines (V8/Chrome, JSC/Safari, SpiderMonkey/Firefox).
38
+ * Native toString() can produce different results for the same float.
39
+ *
40
+ * @param value - Number to convert
41
+ * @param precision - Decimal precision (default: 18)
42
+ */
43
+ FromFloat: (value, precision = DEFAULT_PRECISION) => {
44
+ // Use toFixed(precision) for deterministic conversion across all JS engines
45
+ // This ensures the same string representation regardless of browser
46
+ // and stays within the precision limit of the fixed-point library
47
+ return fpFromDecimal(value.toFixed(precision), precision);
48
+ },
49
+ /**
50
+ * Create a fixed-point number from a string representation
51
+ * @param value - String representation (e.g., "10.5")
52
+ * @param precision - Decimal precision (default: 18)
53
+ */
54
+ FromString: (value, precision = DEFAULT_PRECISION) => {
55
+ return fpFromDecimal(value, precision);
56
+ },
57
+ /**
58
+ * Create a fixed-point number from an integer
59
+ * @param value - Integer value
60
+ * @param precision - Decimal precision (default: 18)
61
+ */
62
+ FromInt: (value, precision = DEFAULT_PRECISION) => {
63
+ return fpFromInt(BigInt(value), 0, precision);
64
+ },
65
+ /**
66
+ * Convert a fixed-point number back to a JavaScript number
67
+ */
68
+ ToFloat: (fp) => {
69
+ return fp.toDecimal();
70
+ },
71
+ /**
72
+ * Get the raw bigint base value from a FixedPoint
73
+ * Used for SoA storage in BigInt64Array
74
+ *
75
+ * Note: This requires storing the precision separately or assuming
76
+ * all values use DEFAULT_PRECISION (18).
77
+ */
78
+ ToRaw: (fp) => {
79
+ return fp.base;
80
+ },
81
+ /**
82
+ * Create a FixedPoint from a raw bigint base value
83
+ * Used for reading from SoA storage (BigInt64Array)
84
+ *
85
+ * @param raw - The raw bigint base value
86
+ * @param precision - The precision (default: 18)
87
+ */
88
+ FromRaw: (raw, precision = DEFAULT_PRECISION) => {
89
+ return new FixedPoint(raw, BigInt(precision));
90
+ },
91
+ // ============ Constants (Quantum naming convention) ============
92
+ /** Zero constant */
93
+ _0: fpFromInt(0n, 0, DEFAULT_PRECISION),
94
+ /** One constant */
95
+ _1: fpFromInt(1n, 0, DEFAULT_PRECISION),
96
+ /** Pi constant */
97
+ Pi: fpFromDecimal('3.14159', DEFAULT_PRECISION),
98
+ /** 2*Pi constant (Quantum naming) */
99
+ Pi2: fpFromDecimal('6.28318', DEFAULT_PRECISION),
100
+ /** Pi/2 constant (Quantum naming) */
101
+ PiOver2: fpFromDecimal('1.57079', DEFAULT_PRECISION),
102
+ // ============ Arithmetic Operations ============
103
+ /** Add two fixed-point numbers */
104
+ Add: (a, b) => a.add(b),
105
+ /** Subtract two fixed-point numbers */
106
+ Sub: (a, b) => a.sub(b),
107
+ /** Multiply two fixed-point numbers */
108
+ Mul: (a, b) => a.mul(b),
109
+ /** Divide two fixed-point numbers */
110
+ Div: (a, b) => a.div(b),
111
+ /** Negate a fixed-point number */
112
+ Neg: (a) => a.neg(),
113
+ // ============ Math Functions ============
114
+ /** Square root of a fixed-point number */
115
+ Sqrt: (a) => a.sqrt(),
116
+ /** Absolute value of a fixed-point number */
117
+ Abs: (a) => a.abs(),
118
+ /** Floor of a fixed-point number */
119
+ Floor: (a) => a.floor(),
120
+ /** Ceiling of a fixed-point number */
121
+ Ceil: (a) => a.ceil(),
122
+ /** Round a fixed-point number */
123
+ Round: (a) => a.round(),
124
+ /** Minimum of two fixed-point numbers */
125
+ Min: (a, b) => FixedPoint.min(a, b),
126
+ /** Maximum of two fixed-point numbers */
127
+ Max: (a, b) => FixedPoint.max(a, b),
128
+ // ============ Comparison ============
129
+ /** Check if two fixed-point numbers are equal */
130
+ Eq: (a, b) => a.eq(b),
131
+ /** Check if first is less than second */
132
+ Lt: (a, b) => a.lt(b),
133
+ /** Check if first is less than or equal to second */
134
+ Lte: (a, b) => a.lte(b),
135
+ /** Check if first is greater than second */
136
+ Gt: (a, b) => a.gt(b),
137
+ /** Check if first is greater than or equal to second */
138
+ Gte: (a, b) => a.gte(b),
139
+ // ============ Interpolation & Clamping ============
140
+ /**
141
+ * Linear interpolation between two values
142
+ * @param a - Start value
143
+ * @param b - End value
144
+ * @param t - Interpolation factor (0-1)
145
+ */
146
+ Lerp: (a, b, t) => {
147
+ return a.add(b.sub(a).mul(t));
148
+ },
149
+ /** Clamp a value between min and max */
150
+ Clamp: (value, min, max) => {
151
+ return FixedPoint.min(FixedPoint.max(value, min), max);
152
+ },
153
+ // ============ Trigonometry ============
154
+ /**
155
+ * Sine approximation using Taylor series (deterministic)
156
+ * Note: Input should be in radians
157
+ */
158
+ Sin: (x) => {
159
+ // Normalize to [-PI, PI] range
160
+ const twoPi = FP.Pi2;
161
+ const pi = FP.Pi;
162
+ // Simple modulo approximation
163
+ let normalized = x;
164
+ while (normalized.gt(pi)) {
165
+ normalized = normalized.sub(twoPi);
166
+ }
167
+ while (normalized.lt(pi.neg())) {
168
+ normalized = normalized.add(twoPi);
169
+ }
170
+ // Taylor series: sin(x) ≈ x - x³/3! + x⁵/5! - x⁷/7!
171
+ const x2 = normalized.mul(normalized);
172
+ const x3 = x2.mul(normalized);
173
+ const x5 = x3.mul(x2);
174
+ const x7 = x5.mul(x2);
175
+ const fact3 = FP.FromInt(6);
176
+ const fact5 = FP.FromInt(120);
177
+ const fact7 = FP.FromInt(5040);
178
+ return normalized.sub(x3.div(fact3)).add(x5.div(fact5)).sub(x7.div(fact7));
179
+ },
180
+ /**
181
+ * Cosine approximation using Taylor series (deterministic)
182
+ * Note: Input should be in radians
183
+ */
184
+ Cos: (x) => {
185
+ // cos(x) = sin(x + PI/2)
186
+ return FP.Sin(x.add(FP.PiOver2));
187
+ },
188
+ /**
189
+ * Approximate atan2 (deterministic)
190
+ * Returns angle in radians
191
+ */
192
+ Atan2: (y, x) => {
193
+ // Simple approximation using polynomial
194
+ const pi = FP.Pi;
195
+ const halfPi = FP.PiOver2;
196
+ const zero = FP._0;
197
+ if (x.isZero() && y.isZero()) {
198
+ return zero;
199
+ }
200
+ if (x.isZero()) {
201
+ return y.isPositive() ? halfPi : halfPi.neg();
202
+ }
203
+ const absY = y.abs();
204
+ const absX = x.abs();
205
+ let angle;
206
+ if (absX.gte(absY)) {
207
+ const ratio = absY.div(absX);
208
+ // Approximate atan using polynomial: atan(t) ≈ t - t³/3 + t⁵/5
209
+ const t2 = ratio.mul(ratio);
210
+ const t3 = t2.mul(ratio);
211
+ const t5 = t3.mul(t2);
212
+ angle = ratio.sub(t3.div(FP.FromInt(3))).add(t5.div(FP.FromInt(5)));
213
+ }
214
+ else {
215
+ const ratio = absX.div(absY);
216
+ const t2 = ratio.mul(ratio);
217
+ const t3 = t2.mul(ratio);
218
+ const t5 = t3.mul(t2);
219
+ angle = halfPi.sub(ratio.sub(t3.div(FP.FromInt(3))).add(t5.div(FP.FromInt(5))));
220
+ }
221
+ // Adjust for quadrant
222
+ if (x.isNegative()) {
223
+ angle = pi.sub(angle);
224
+ }
225
+ if (y.isNegative()) {
226
+ angle = angle.neg();
227
+ }
228
+ return angle;
229
+ },
230
+ };
231
+ /**
232
+ * FPVector2 - Fixed-point 2D vector utilities (Unity/Quantum style)
233
+ */
234
+ export const FPVector2 = {
235
+ // ============ Creation ============
236
+ /** Create a new vector from FixedPoint values */
237
+ Create: (x, y) => ({ x, y }),
238
+ /** Create a vector from float numbers */
239
+ FromFloat: (x, y) => ({
240
+ x: FP.FromFloat(x),
241
+ y: FP.FromFloat(y),
242
+ }),
243
+ // ============ Constants ============
244
+ /** Zero vector */
245
+ Zero: { x: FP._0, y: FP._0 },
246
+ /** One vector (1, 1) */
247
+ One: { x: FP._1, y: FP._1 },
248
+ /** Up direction (0, 1) - Unity convention */
249
+ Up: { x: FP._0, y: FP._1 },
250
+ /** Right direction (1, 0) - Unity convention */
251
+ Right: { x: FP._1, y: FP._0 },
252
+ // ============ Operations ============
253
+ /** Add two vectors */
254
+ Add: (a, b) => ({
255
+ x: a.x.add(b.x),
256
+ y: a.y.add(b.y),
257
+ }),
258
+ /** Subtract two vectors */
259
+ Sub: (a, b) => ({
260
+ x: a.x.sub(b.x),
261
+ y: a.y.sub(b.y),
262
+ }),
263
+ /** Scale a vector by a scalar */
264
+ Scale: (v, s) => ({
265
+ x: v.x.mul(s),
266
+ y: v.y.mul(s),
267
+ }),
268
+ /** Get the magnitude (length) of a vector - Unity naming */
269
+ Magnitude: (v) => {
270
+ return v.x.mul(v.x).add(v.y.mul(v.y)).sqrt();
271
+ },
272
+ /** Get the squared magnitude of a vector (faster than Magnitude) - Unity naming */
273
+ SqrMagnitude: (v) => {
274
+ return v.x.mul(v.x).add(v.y.mul(v.y));
275
+ },
276
+ /** Normalize a vector (returns new vector) */
277
+ Normalize: (v) => {
278
+ const len = FPVector2.Magnitude(v);
279
+ if (len.isZero()) {
280
+ return { x: FP._0, y: FP._0 };
281
+ }
282
+ return {
283
+ x: v.x.div(len),
284
+ y: v.y.div(len),
285
+ };
286
+ },
287
+ /** Dot product of two vectors */
288
+ Dot: (a, b) => {
289
+ return a.x.mul(b.x).add(a.y.mul(b.y));
290
+ },
291
+ /** Distance between two vectors */
292
+ Distance: (a, b) => {
293
+ const dx = b.x.sub(a.x);
294
+ const dy = b.y.sub(a.y);
295
+ return dx.mul(dx).add(dy.mul(dy)).sqrt();
296
+ },
297
+ /** Squared distance between two vectors (faster than Distance) */
298
+ SqrDistance: (a, b) => {
299
+ const dx = b.x.sub(a.x);
300
+ const dy = b.y.sub(a.y);
301
+ return dx.mul(dx).add(dy.mul(dy));
302
+ },
303
+ /** Linear interpolation between two vectors */
304
+ Lerp: (a, b, t) => ({
305
+ x: FP.Lerp(a.x, b.x, t),
306
+ y: FP.Lerp(a.y, b.y, t),
307
+ }),
308
+ // ============ Conversion ============
309
+ /** Convert to plain object with float values (for display/serialization) */
310
+ ToFloat: (v) => ({
311
+ x: v.x.toDecimal(),
312
+ y: v.y.toDecimal(),
313
+ }),
314
+ };
315
+ /**
316
+ * FPVector3 - Fixed-point 3D vector utilities (Unity/Quantum style)
317
+ */
318
+ export const FPVector3 = {
319
+ // ============ Creation ============
320
+ /** Create a new 3D vector from FixedPoint values */
321
+ Create: (x, y, z) => ({
322
+ x,
323
+ y,
324
+ z,
325
+ }),
326
+ /** Create a 3D vector from float numbers */
327
+ FromFloat: (x, y, z) => ({
328
+ x: FP.FromFloat(x),
329
+ y: FP.FromFloat(y),
330
+ z: FP.FromFloat(z),
331
+ }),
332
+ // ============ Constants ============
333
+ /** Zero vector */
334
+ Zero: { x: FP._0, y: FP._0, z: FP._0 },
335
+ /** One vector (1, 1, 1) */
336
+ One: { x: FP._1, y: FP._1, z: FP._1 },
337
+ /** Up direction (0, 1, 0) - Unity convention */
338
+ Up: { x: FP._0, y: FP._1, z: FP._0 },
339
+ /** Right direction (1, 0, 0) - Unity convention */
340
+ Right: { x: FP._1, y: FP._0, z: FP._0 },
341
+ /** Forward direction (0, 0, 1) - Unity convention */
342
+ Forward: { x: FP._0, y: FP._0, z: FP._1 },
343
+ // ============ Operations ============
344
+ /** Add two 3D vectors */
345
+ Add: (a, b) => ({
346
+ x: a.x.add(b.x),
347
+ y: a.y.add(b.y),
348
+ z: a.z.add(b.z),
349
+ }),
350
+ /** Subtract two 3D vectors */
351
+ Sub: (a, b) => ({
352
+ x: a.x.sub(b.x),
353
+ y: a.y.sub(b.y),
354
+ z: a.z.sub(b.z),
355
+ }),
356
+ /** Scale a 3D vector by a scalar */
357
+ Scale: (v, s) => ({
358
+ x: v.x.mul(s),
359
+ y: v.y.mul(s),
360
+ z: v.z.mul(s),
361
+ }),
362
+ /** Get the magnitude (length) of a 3D vector - Unity naming */
363
+ Magnitude: (v) => {
364
+ return v.x.mul(v.x).add(v.y.mul(v.y)).add(v.z.mul(v.z)).sqrt();
365
+ },
366
+ /** Get the squared magnitude of a 3D vector (faster than Magnitude) - Unity naming */
367
+ SqrMagnitude: (v) => {
368
+ return v.x.mul(v.x).add(v.y.mul(v.y)).add(v.z.mul(v.z));
369
+ },
370
+ /** Normalize a 3D vector (returns new vector) */
371
+ Normalize: (v) => {
372
+ const len = FPVector3.Magnitude(v);
373
+ if (len.isZero()) {
374
+ return { x: FP._0, y: FP._0, z: FP._0 };
375
+ }
376
+ return {
377
+ x: v.x.div(len),
378
+ y: v.y.div(len),
379
+ z: v.z.div(len),
380
+ };
381
+ },
382
+ /** Dot product of two 3D vectors */
383
+ Dot: (a, b) => {
384
+ return a.x.mul(b.x).add(a.y.mul(b.y)).add(a.z.mul(b.z));
385
+ },
386
+ /** Cross product of two 3D vectors */
387
+ Cross: (a, b) => ({
388
+ x: a.y.mul(b.z).sub(a.z.mul(b.y)),
389
+ y: a.z.mul(b.x).sub(a.x.mul(b.z)),
390
+ z: a.x.mul(b.y).sub(a.y.mul(b.x)),
391
+ }),
392
+ /** Distance between two 3D vectors */
393
+ Distance: (a, b) => {
394
+ const dx = b.x.sub(a.x);
395
+ const dy = b.y.sub(a.y);
396
+ const dz = b.z.sub(a.z);
397
+ return dx.mul(dx).add(dy.mul(dy)).add(dz.mul(dz)).sqrt();
398
+ },
399
+ /** Squared distance between two 3D vectors (faster than Distance) */
400
+ SqrDistance: (a, b) => {
401
+ const dx = b.x.sub(a.x);
402
+ const dy = b.y.sub(a.y);
403
+ const dz = b.z.sub(a.z);
404
+ return dx.mul(dx).add(dy.mul(dy)).add(dz.mul(dz));
405
+ },
406
+ /** Linear interpolation between two 3D vectors */
407
+ Lerp: (a, b, t) => ({
408
+ x: FP.Lerp(a.x, b.x, t),
409
+ y: FP.Lerp(a.y, b.y, t),
410
+ z: FP.Lerp(a.z, b.z, t),
411
+ }),
412
+ // ============ Conversion ============
413
+ /** Convert to plain object with float values (for display/serialization) */
414
+ ToFloat: (v) => ({
415
+ x: v.x.toDecimal(),
416
+ y: v.y.toDecimal(),
417
+ z: v.z.toDecimal(),
418
+ }),
419
+ };
420
+ //# sourceMappingURL=FixedMath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FixedMath.js","sourceRoot":"","sources":["../src/FixedMath.ts"],"names":[],"mappings":"AAAA;;;;;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AAC,SAAS,EAAE;QAClB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE;KACnB,CAAC;CACH,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Phalanx Math - Deterministic Fixed-Point Math Library
3
+ *
4
+ * Provides cross-platform deterministic arithmetic for lockstep multiplayer games.
5
+ * All operations produce identical results regardless of hardware or platform.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ export { FixedPoint, FP, FPVector2, FPVector3, } from './FixedMath.js';
10
+ export type { FPVector2 as FPVector2Interface, FPVector3 as FPVector3Interface, } from './FixedMath.js';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAEL,UAAU,EAEV,EAAE,EACF,SAAS,EACT,SAAS,GACV,MAAM,gBAAgB,CAAC;AAExB,YAAY,EAEV,SAAS,IAAI,kBAAkB,EAE/B,SAAS,IAAI,kBAAkB,GAChC,MAAM,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Phalanx Math - Deterministic Fixed-Point Math Library
3
+ *
4
+ * Provides cross-platform deterministic arithmetic for lockstep multiplayer games.
5
+ * All operations produce identical results regardless of hardware or platform.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ export {
10
+ // Core types
11
+ FixedPoint,
12
+ // Unified API (Unity/Quantum style)
13
+ FP, FPVector2, FPVector3, } from './FixedMath.js';
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO;AACL,aAAa;AACb,UAAU;AACV,oCAAoC;AACpC,EAAE,EACF,SAAS,EACT,SAAS,GACV,MAAM,gBAAgB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@phalanx-engine/math",
3
+ "version": "0.1.0",
4
+ "description": "Deterministic fixed-point math library for Phalanx Engine - ensures identical calculations across all platforms",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "keywords": [
15
+ "fixed-point",
16
+ "deterministic",
17
+ "math",
18
+ "game-math",
19
+ "cross-platform",
20
+ "phalanx"
21
+ ],
22
+ "author": "",
23
+ "license": "MIT",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/phaeton-forge/phalanx-engine.git",
27
+ "directory": "phalanx-math"
28
+ },
29
+ "bugs": "https://github.com/phaeton-forge/phalanx-engine/issues",
30
+ "homepage": "https://github.com/phaeton-forge/phalanx-engine/tree/main/phalanx-math#readme",
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "engines": {
35
+ "node": ">=24.0.0 <25.0.0"
36
+ },
37
+ "files": [
38
+ "dist",
39
+ "README.md"
40
+ ],
41
+ "dependencies": {
42
+ "@hastom/fixed-point": "^4.3.1"
43
+ },
44
+ "devDependencies": {
45
+ "@types/node": "^20.0.0",
46
+ "rimraf": "^5.0.0",
47
+ "typescript": "^5.3.0",
48
+ "vitest": "^1.0.0"
49
+ },
50
+ "scripts": {
51
+ "build": "tsc",
52
+ "dev": "tsc --watch",
53
+ "clean": "rimraf dist",
54
+ "test": "vitest run --passWithNoTests",
55
+ "test:watch": "vitest"
56
+ }
57
+ }