@vib3code/sdk 2.0.1 → 2.0.3-canary.75a3290

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.
Files changed (136) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/DOCS/AGENT_HARNESS_ARCHITECTURE.md +243 -0
  3. package/DOCS/CLI_ONBOARDING.md +1 -1
  4. package/DOCS/CROSS_SITE_DESIGN_PATTERNS.md +117 -0
  5. package/DOCS/EPIC_SCROLL_EVENTS.md +773 -0
  6. package/DOCS/HANDOFF_LANDING_PAGE.md +154 -0
  7. package/DOCS/HANDOFF_SDK_DEVELOPMENT.md +493 -0
  8. package/DOCS/MULTIVIZ_CHOREOGRAPHY_PATTERNS.md +937 -0
  9. package/DOCS/PRODUCT_STRATEGY.md +63 -0
  10. package/DOCS/README.md +103 -0
  11. package/DOCS/REFERENCE_SCROLL_ANALYSIS.md +97 -0
  12. package/DOCS/ROADMAP.md +111 -0
  13. package/DOCS/SCROLL_TIMELINE_v3.md +269 -0
  14. package/DOCS/SITE_REFACTOR_PLAN.md +100 -0
  15. package/DOCS/STATUS.md +24 -0
  16. package/DOCS/SYSTEM_INVENTORY.md +33 -30
  17. package/DOCS/VISUAL_ANALYSIS_CLICKERSS.md +85 -0
  18. package/DOCS/VISUAL_ANALYSIS_FACETAD.md +133 -0
  19. package/DOCS/VISUAL_ANALYSIS_SIMONE.md +95 -0
  20. package/DOCS/VISUAL_ANALYSIS_TABLESIDE.md +86 -0
  21. package/DOCS/{BLUEPRINT_EXECUTION_PLAN_2026-01-07.md → archive/BLUEPRINT_EXECUTION_PLAN_2026-01-07.md} +1 -1
  22. package/DOCS/{DEV_TRACK_ANALYSIS.md → archive/DEV_TRACK_ANALYSIS.md} +3 -0
  23. package/DOCS/{SYSTEM_AUDIT_2026-01-30.md → archive/SYSTEM_AUDIT_2026-01-30.md} +3 -0
  24. package/DOCS/{DEV_TRACK_SESSION_2026-01-31.md → dev-tracks/DEV_TRACK_SESSION_2026-01-31.md} +1 -1
  25. package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-06.md +231 -0
  26. package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-13.md +127 -0
  27. package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-15.md +142 -0
  28. package/DOCS/dev-tracks/README.md +10 -0
  29. package/README.md +26 -13
  30. package/cpp/CMakeLists.txt +236 -0
  31. package/cpp/bindings/embind.cpp +269 -0
  32. package/cpp/build.sh +129 -0
  33. package/cpp/geometry/Crystal.cpp +103 -0
  34. package/cpp/geometry/Fractal.cpp +136 -0
  35. package/cpp/geometry/GeometryGenerator.cpp +262 -0
  36. package/cpp/geometry/KleinBottle.cpp +71 -0
  37. package/cpp/geometry/Sphere.cpp +134 -0
  38. package/cpp/geometry/Tesseract.cpp +94 -0
  39. package/cpp/geometry/Tetrahedron.cpp +83 -0
  40. package/cpp/geometry/Torus.cpp +65 -0
  41. package/cpp/geometry/WarpFunctions.cpp +238 -0
  42. package/cpp/geometry/Wave.cpp +85 -0
  43. package/cpp/include/vib3_ffi.h +238 -0
  44. package/cpp/math/Mat4x4.cpp +409 -0
  45. package/cpp/math/Mat4x4.hpp +209 -0
  46. package/cpp/math/Projection.cpp +142 -0
  47. package/cpp/math/Projection.hpp +148 -0
  48. package/cpp/math/Rotor4D.cpp +322 -0
  49. package/cpp/math/Rotor4D.hpp +204 -0
  50. package/cpp/math/Vec4.cpp +303 -0
  51. package/cpp/math/Vec4.hpp +225 -0
  52. package/cpp/src/vib3_ffi.cpp +607 -0
  53. package/cpp/tests/Geometry_test.cpp +213 -0
  54. package/cpp/tests/Mat4x4_test.cpp +494 -0
  55. package/cpp/tests/Projection_test.cpp +298 -0
  56. package/cpp/tests/Rotor4D_test.cpp +423 -0
  57. package/cpp/tests/Vec4_test.cpp +489 -0
  58. package/package.json +40 -27
  59. package/src/agent/index.js +1 -3
  60. package/src/agent/mcp/MCPServer.js +918 -0
  61. package/src/agent/mcp/index.js +1 -1
  62. package/src/agent/mcp/stdio-server.js +264 -0
  63. package/src/agent/mcp/tools.js +454 -0
  64. package/src/cli/index.js +374 -44
  65. package/src/core/CanvasManager.js +97 -204
  66. package/src/core/ErrorReporter.js +1 -1
  67. package/src/core/Parameters.js +1 -1
  68. package/src/core/VIB3Engine.js +93 -4
  69. package/src/core/VitalitySystem.js +53 -0
  70. package/src/core/index.js +18 -0
  71. package/src/core/renderers/FacetedRendererAdapter.js +10 -9
  72. package/src/core/renderers/HolographicRendererAdapter.js +13 -9
  73. package/src/core/renderers/QuantumRendererAdapter.js +11 -7
  74. package/src/creative/AestheticMapper.js +628 -0
  75. package/src/creative/ChoreographyPlayer.js +481 -0
  76. package/src/creative/index.js +11 -0
  77. package/src/export/TradingCardManager.js +3 -4
  78. package/src/export/index.js +11 -1
  79. package/src/faceted/FacetedSystem.js +241 -388
  80. package/src/holograms/HolographicVisualizer.js +29 -12
  81. package/src/holograms/RealHolographicSystem.js +194 -43
  82. package/src/math/index.js +7 -7
  83. package/src/polychora/PolychoraSystem.js +77 -0
  84. package/src/quantum/QuantumEngine.js +103 -66
  85. package/src/quantum/QuantumVisualizer.js +7 -2
  86. package/src/reactivity/index.js +3 -5
  87. package/src/render/LayerPresetManager.js +372 -0
  88. package/src/render/LayerReactivityBridge.js +344 -0
  89. package/src/render/LayerRelationshipGraph.js +610 -0
  90. package/src/render/MultiCanvasBridge.js +148 -25
  91. package/src/render/UnifiedRenderBridge.js +3 -0
  92. package/src/render/index.js +27 -2
  93. package/src/scene/index.js +4 -4
  94. package/src/shaders/faceted/faceted.frag.glsl +220 -80
  95. package/src/shaders/faceted/faceted.frag.wgsl +138 -97
  96. package/src/shaders/holographic/holographic.frag.glsl +28 -9
  97. package/src/shaders/holographic/holographic.frag.wgsl +107 -38
  98. package/src/shaders/quantum/quantum.frag.glsl +1 -0
  99. package/src/shaders/quantum/quantum.frag.wgsl +1 -1
  100. package/src/testing/ParallelTestFramework.js +2 -2
  101. package/src/viewer/GalleryUI.js +17 -0
  102. package/src/viewer/ViewerPortal.js +2 -2
  103. package/src/viewer/index.js +1 -1
  104. package/tools/headless-renderer.js +258 -0
  105. package/tools/shader-sync-verify.js +8 -4
  106. package/tools/site-analysis/all-reports.json +32 -0
  107. package/tools/site-analysis/combined-analysis.md +50 -0
  108. package/tools/site-analyzer.mjs +779 -0
  109. package/tools/visual-catalog/capture.js +276 -0
  110. package/tools/visual-catalog/composite.js +138 -0
  111. package/types/adaptive-sdk.d.ts +204 -5
  112. package/types/agent/cli.d.ts +78 -0
  113. package/types/agent/index.d.ts +18 -0
  114. package/types/agent/mcp.d.ts +87 -0
  115. package/types/agent/telemetry.d.ts +190 -0
  116. package/types/core/VIB3Engine.d.ts +26 -0
  117. package/types/core/index.d.ts +261 -0
  118. package/types/creative/AestheticMapper.d.ts +72 -0
  119. package/types/creative/ChoreographyPlayer.d.ts +96 -0
  120. package/types/creative/index.d.ts +17 -0
  121. package/types/export/index.d.ts +243 -0
  122. package/types/geometry/index.d.ts +164 -0
  123. package/types/math/index.d.ts +214 -0
  124. package/types/render/LayerPresetManager.d.ts +78 -0
  125. package/types/render/LayerReactivityBridge.d.ts +85 -0
  126. package/types/render/LayerRelationshipGraph.d.ts +174 -0
  127. package/types/render/index.d.ts +3 -0
  128. package/types/scene/index.d.ts +204 -0
  129. package/types/systems/index.d.ts +244 -0
  130. package/types/variations/index.d.ts +62 -0
  131. package/types/viewer/index.d.ts +225 -0
  132. /package/DOCS/{DEV_TRACK_PLAN_2026-01-07.md → archive/DEV_TRACK_PLAN_2026-01-07.md} +0 -0
  133. /package/DOCS/{SESSION_014_PLAN.md → archive/SESSION_014_PLAN.md} +0 -0
  134. /package/DOCS/{SESSION_LOG_2026-01-07.md → archive/SESSION_LOG_2026-01-07.md} +0 -0
  135. /package/DOCS/{STRATEGIC_BLUEPRINT_2026-01-07.md → archive/STRATEGIC_BLUEPRINT_2026-01-07.md} +0 -0
  136. /package/src/viewer/{ReactivityManager.js → ViewerInputHandler.js} +0 -0
@@ -0,0 +1,303 @@
1
+ /**
2
+ * Vec4.cpp - 4D Vector Implementation
3
+ */
4
+
5
+ #include "Vec4.hpp"
6
+ #include <random>
7
+ #include <limits>
8
+
9
+ namespace vib3 {
10
+
11
+ // Static random generator for randomUnit()
12
+ static std::mt19937& getRandomEngine() {
13
+ static std::random_device rd;
14
+ static std::mt19937 gen(rd());
15
+ return gen;
16
+ }
17
+
18
+ Vec4 Vec4::randomUnit() noexcept {
19
+ // Marsaglia method for uniform distribution on S³
20
+ std::normal_distribution<float> dist(0.0f, 1.0f);
21
+ auto& gen = getRandomEngine();
22
+
23
+ Vec4 v(dist(gen), dist(gen), dist(gen), dist(gen));
24
+ v.normalize();
25
+ return v;
26
+ }
27
+
28
+ // Arithmetic operators
29
+
30
+ #if defined(VIB3_HAS_SSE41)
31
+
32
+ Vec4 Vec4::operator+(const Vec4& other) const noexcept {
33
+ return Vec4(_mm_add_ps(simd, other.simd));
34
+ }
35
+
36
+ Vec4 Vec4::operator-(const Vec4& other) const noexcept {
37
+ return Vec4(_mm_sub_ps(simd, other.simd));
38
+ }
39
+
40
+ Vec4 Vec4::operator*(float scalar) const noexcept {
41
+ return Vec4(_mm_mul_ps(simd, _mm_set1_ps(scalar)));
42
+ }
43
+
44
+ Vec4 Vec4::operator/(float scalar) const noexcept {
45
+ return Vec4(_mm_div_ps(simd, _mm_set1_ps(scalar)));
46
+ }
47
+
48
+ Vec4 Vec4::operator-() const noexcept {
49
+ return Vec4(_mm_xor_ps(simd, _mm_set1_ps(-0.0f)));
50
+ }
51
+
52
+ float Vec4::dot(const Vec4& other) const noexcept {
53
+ __m128 mul = _mm_mul_ps(simd, other.simd);
54
+ __m128 sum = _mm_hadd_ps(mul, mul);
55
+ sum = _mm_hadd_ps(sum, sum);
56
+ return _mm_cvtss_f32(sum);
57
+ }
58
+
59
+ Vec4 Vec4::min(const Vec4& other) const noexcept {
60
+ return Vec4(_mm_min_ps(simd, other.simd));
61
+ }
62
+
63
+ Vec4 Vec4::max(const Vec4& other) const noexcept {
64
+ return Vec4(_mm_max_ps(simd, other.simd));
65
+ }
66
+
67
+ Vec4 Vec4::abs() const noexcept {
68
+ __m128 mask = _mm_castsi128_ps(_mm_set1_epi32(0x7FFFFFFF));
69
+ return Vec4(_mm_and_ps(simd, mask));
70
+ }
71
+
72
+ #elif defined(__EMSCRIPTEN__)
73
+
74
+ Vec4 Vec4::operator+(const Vec4& other) const noexcept {
75
+ return Vec4(wasm_f32x4_add(simd, other.simd));
76
+ }
77
+
78
+ Vec4 Vec4::operator-(const Vec4& other) const noexcept {
79
+ return Vec4(wasm_f32x4_sub(simd, other.simd));
80
+ }
81
+
82
+ Vec4 Vec4::operator*(float scalar) const noexcept {
83
+ return Vec4(wasm_f32x4_mul(simd, wasm_f32x4_splat(scalar)));
84
+ }
85
+
86
+ Vec4 Vec4::operator/(float scalar) const noexcept {
87
+ return Vec4(wasm_f32x4_div(simd, wasm_f32x4_splat(scalar)));
88
+ }
89
+
90
+ Vec4 Vec4::operator-() const noexcept {
91
+ return Vec4(wasm_f32x4_neg(simd));
92
+ }
93
+
94
+ float Vec4::dot(const Vec4& other) const noexcept {
95
+ v128_t mul = wasm_f32x4_mul(simd, other.simd);
96
+ return wasm_f32x4_extract_lane(mul, 0) +
97
+ wasm_f32x4_extract_lane(mul, 1) +
98
+ wasm_f32x4_extract_lane(mul, 2) +
99
+ wasm_f32x4_extract_lane(mul, 3);
100
+ }
101
+
102
+ Vec4 Vec4::min(const Vec4& other) const noexcept {
103
+ return Vec4(wasm_f32x4_min(simd, other.simd));
104
+ }
105
+
106
+ Vec4 Vec4::max(const Vec4& other) const noexcept {
107
+ return Vec4(wasm_f32x4_max(simd, other.simd));
108
+ }
109
+
110
+ Vec4 Vec4::abs() const noexcept {
111
+ return Vec4(wasm_f32x4_abs(simd));
112
+ }
113
+
114
+ #else
115
+ // Scalar fallback
116
+
117
+ Vec4 Vec4::operator+(const Vec4& other) const noexcept {
118
+ return Vec4(x + other.x, y + other.y, z + other.z, w + other.w);
119
+ }
120
+
121
+ Vec4 Vec4::operator-(const Vec4& other) const noexcept {
122
+ return Vec4(x - other.x, y - other.y, z - other.z, w - other.w);
123
+ }
124
+
125
+ Vec4 Vec4::operator*(float scalar) const noexcept {
126
+ return Vec4(x * scalar, y * scalar, z * scalar, w * scalar);
127
+ }
128
+
129
+ Vec4 Vec4::operator/(float scalar) const noexcept {
130
+ float inv = 1.0f / scalar;
131
+ return Vec4(x * inv, y * inv, z * inv, w * inv);
132
+ }
133
+
134
+ Vec4 Vec4::operator-() const noexcept {
135
+ return Vec4(-x, -y, -z, -w);
136
+ }
137
+
138
+ float Vec4::dot(const Vec4& other) const noexcept {
139
+ return x * other.x + y * other.y + z * other.z + w * other.w;
140
+ }
141
+
142
+ Vec4 Vec4::min(const Vec4& other) const noexcept {
143
+ return Vec4(
144
+ std::min(x, other.x),
145
+ std::min(y, other.y),
146
+ std::min(z, other.z),
147
+ std::min(w, other.w)
148
+ );
149
+ }
150
+
151
+ Vec4 Vec4::max(const Vec4& other) const noexcept {
152
+ return Vec4(
153
+ std::max(x, other.x),
154
+ std::max(y, other.y),
155
+ std::max(z, other.z),
156
+ std::max(w, other.w)
157
+ );
158
+ }
159
+
160
+ Vec4 Vec4::abs() const noexcept {
161
+ return Vec4(std::abs(x), std::abs(y), std::abs(z), std::abs(w));
162
+ }
163
+
164
+ #endif
165
+
166
+ // Compound assignment (always scalar for simplicity)
167
+
168
+ Vec4& Vec4::operator+=(const Vec4& other) noexcept {
169
+ *this = *this + other;
170
+ return *this;
171
+ }
172
+
173
+ Vec4& Vec4::operator-=(const Vec4& other) noexcept {
174
+ *this = *this - other;
175
+ return *this;
176
+ }
177
+
178
+ Vec4& Vec4::operator*=(float scalar) noexcept {
179
+ *this = *this * scalar;
180
+ return *this;
181
+ }
182
+
183
+ Vec4& Vec4::operator/=(float scalar) noexcept {
184
+ *this = *this / scalar;
185
+ return *this;
186
+ }
187
+
188
+ // Comparison
189
+
190
+ bool Vec4::operator==(const Vec4& other) const noexcept {
191
+ return x == other.x && y == other.y && z == other.z && w == other.w;
192
+ }
193
+
194
+ bool Vec4::operator!=(const Vec4& other) const noexcept {
195
+ return !(*this == other);
196
+ }
197
+
198
+ // Length and normalization
199
+
200
+ float Vec4::lengthSquared() const noexcept {
201
+ return dot(*this);
202
+ }
203
+
204
+ float Vec4::length() const noexcept {
205
+ return std::sqrt(lengthSquared());
206
+ }
207
+
208
+ Vec4 Vec4::normalized() const noexcept {
209
+ float len = length();
210
+ if (len > 0) {
211
+ return *this / len;
212
+ }
213
+ return Vec4::zero();
214
+ }
215
+
216
+ void Vec4::normalize() noexcept {
217
+ float len = length();
218
+ if (len > 0) {
219
+ *this /= len;
220
+ }
221
+ }
222
+
223
+ // Distance
224
+
225
+ float Vec4::distanceTo(const Vec4& other) const noexcept {
226
+ return (*this - other).length();
227
+ }
228
+
229
+ float Vec4::distanceSquaredTo(const Vec4& other) const noexcept {
230
+ return (*this - other).lengthSquared();
231
+ }
232
+
233
+ // Interpolation
234
+
235
+ Vec4 Vec4::lerp(const Vec4& other, float t) const noexcept {
236
+ return *this + (other - *this) * t;
237
+ }
238
+
239
+ // Clamp
240
+
241
+ Vec4 Vec4::clamp(const Vec4& minVal, const Vec4& maxVal) const noexcept {
242
+ return this->max(minVal).min(maxVal);
243
+ }
244
+
245
+ // Projection and reflection
246
+
247
+ Vec4 Vec4::projectOnto(const Vec4& other) const noexcept {
248
+ float d = other.dot(other);
249
+ if (d > 0) {
250
+ return other * (dot(other) / d);
251
+ }
252
+ return Vec4::zero();
253
+ }
254
+
255
+ Vec4 Vec4::reflect(const Vec4& normal) const noexcept {
256
+ return *this - normal * (2.0f * dot(normal));
257
+ }
258
+
259
+ // Validation
260
+
261
+ bool Vec4::isZero(float epsilon) const noexcept {
262
+ return lengthSquared() < epsilon * epsilon;
263
+ }
264
+
265
+ bool Vec4::isNormalized(float epsilon) const noexcept {
266
+ return std::abs(lengthSquared() - 1.0f) < epsilon;
267
+ }
268
+
269
+ // 4D -> 3D Projections
270
+
271
+ std::array<float, 3> Vec4::projectPerspective(float distance) const noexcept {
272
+ float denom = distance - w;
273
+
274
+ // Handle singularity
275
+ if (std::abs(denom) < 1e-6f) {
276
+ float sign = (denom >= 0) ? 1.0f : -1.0f;
277
+ constexpr float large = 1e6f;
278
+ return {x * sign * large, y * sign * large, z * sign * large};
279
+ }
280
+
281
+ float factor = distance / denom;
282
+ return {x * factor, y * factor, z * factor};
283
+ }
284
+
285
+ std::array<float, 3> Vec4::projectStereographic() const noexcept {
286
+ float denom = 1.0f - w;
287
+
288
+ // Handle singularity at w = 1
289
+ if (std::abs(denom) < 1e-6f) {
290
+ constexpr float large = 1e6f;
291
+ float sign = (x + y + z >= 0) ? 1.0f : -1.0f;
292
+ return {sign * large, sign * large, sign * large};
293
+ }
294
+
295
+ float factor = 1.0f / denom;
296
+ return {x * factor, y * factor, z * factor};
297
+ }
298
+
299
+ std::array<float, 3> Vec4::projectOrthographic() const noexcept {
300
+ return {x, y, z};
301
+ }
302
+
303
+ } // namespace vib3
@@ -0,0 +1,225 @@
1
+ /**
2
+ * Vec4.hpp - 4D Vector for VIB3+ SDK
3
+ *
4
+ * SIMD-optimized 4D vector with full geometric operations.
5
+ * Uses float[4] for GPU compatibility and SIMD alignment.
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include <array>
11
+ #include <cmath>
12
+ #include <numbers>
13
+ #include <algorithm>
14
+
15
+ #ifdef VIB3_HAS_SSE41
16
+ #include <smmintrin.h>
17
+ #endif
18
+
19
+ #ifdef __EMSCRIPTEN__
20
+ #include <wasm_simd128.h>
21
+ #endif
22
+
23
+ namespace vib3 {
24
+
25
+ /**
26
+ * 4D Vector class
27
+ *
28
+ * Layout: [x, y, z, w] where w is the 4th dimension (not homogeneous coordinate)
29
+ */
30
+ class alignas(16) Vec4 {
31
+ public:
32
+ union {
33
+ struct { float x, y, z, w; };
34
+ std::array<float, 4> data;
35
+ #ifdef VIB3_HAS_SSE41
36
+ __m128 simd;
37
+ #endif
38
+ #ifdef __EMSCRIPTEN__
39
+ v128_t simd;
40
+ #endif
41
+ };
42
+
43
+ // Constructors
44
+ constexpr Vec4() noexcept : x(0), y(0), z(0), w(0) {}
45
+ constexpr Vec4(float x, float y, float z, float w) noexcept : x(x), y(y), z(z), w(w) {}
46
+ constexpr explicit Vec4(float scalar) noexcept : x(scalar), y(scalar), z(scalar), w(scalar) {}
47
+ constexpr Vec4(const std::array<float, 4>& arr) noexcept : data(arr) {}
48
+
49
+ #ifdef VIB3_HAS_SSE41
50
+ Vec4(__m128 v) noexcept : simd(v) {}
51
+ #endif
52
+
53
+ #ifdef __EMSCRIPTEN__
54
+ Vec4(v128_t v) noexcept : simd(v) {}
55
+ #endif
56
+
57
+ // Static factories
58
+ static constexpr Vec4 zero() noexcept { return Vec4(0, 0, 0, 0); }
59
+ static constexpr Vec4 one() noexcept { return Vec4(1, 1, 1, 1); }
60
+ static constexpr Vec4 unitX() noexcept { return Vec4(1, 0, 0, 0); }
61
+ static constexpr Vec4 unitY() noexcept { return Vec4(0, 1, 0, 0); }
62
+ static constexpr Vec4 unitZ() noexcept { return Vec4(0, 0, 1, 0); }
63
+ static constexpr Vec4 unitW() noexcept { return Vec4(0, 0, 0, 1); }
64
+
65
+ /**
66
+ * Create random unit vector on S³
67
+ */
68
+ static Vec4 randomUnit() noexcept;
69
+
70
+ // Element access
71
+ constexpr float& operator[](size_t i) noexcept { return data[i]; }
72
+ constexpr const float& operator[](size_t i) const noexcept { return data[i]; }
73
+
74
+ // Arithmetic operators
75
+ Vec4 operator+(const Vec4& other) const noexcept;
76
+ Vec4 operator-(const Vec4& other) const noexcept;
77
+ Vec4 operator*(float scalar) const noexcept;
78
+ Vec4 operator/(float scalar) const noexcept;
79
+ Vec4 operator-() const noexcept;
80
+
81
+ Vec4& operator+=(const Vec4& other) noexcept;
82
+ Vec4& operator-=(const Vec4& other) noexcept;
83
+ Vec4& operator*=(float scalar) noexcept;
84
+ Vec4& operator/=(float scalar) noexcept;
85
+
86
+ // Comparison
87
+ bool operator==(const Vec4& other) const noexcept;
88
+ bool operator!=(const Vec4& other) const noexcept;
89
+
90
+ /**
91
+ * Dot product
92
+ */
93
+ float dot(const Vec4& other) const noexcept;
94
+
95
+ /**
96
+ * Squared length (magnitude²)
97
+ */
98
+ float lengthSquared() const noexcept;
99
+
100
+ /**
101
+ * Length (magnitude)
102
+ */
103
+ float length() const noexcept;
104
+
105
+ /**
106
+ * Normalize to unit length
107
+ */
108
+ Vec4 normalized() const noexcept;
109
+
110
+ /**
111
+ * Normalize in place
112
+ */
113
+ void normalize() noexcept;
114
+
115
+ /**
116
+ * Distance to another point
117
+ */
118
+ float distanceTo(const Vec4& other) const noexcept;
119
+
120
+ /**
121
+ * Squared distance to another point
122
+ */
123
+ float distanceSquaredTo(const Vec4& other) const noexcept;
124
+
125
+ /**
126
+ * Linear interpolation
127
+ */
128
+ Vec4 lerp(const Vec4& other, float t) const noexcept;
129
+
130
+ /**
131
+ * Component-wise minimum
132
+ */
133
+ Vec4 min(const Vec4& other) const noexcept;
134
+
135
+ /**
136
+ * Component-wise maximum
137
+ */
138
+ Vec4 max(const Vec4& other) const noexcept;
139
+
140
+ /**
141
+ * Component-wise clamp
142
+ */
143
+ Vec4 clamp(const Vec4& minVal, const Vec4& maxVal) const noexcept;
144
+
145
+ /**
146
+ * Component-wise absolute value
147
+ */
148
+ Vec4 abs() const noexcept;
149
+
150
+ /**
151
+ * Project onto another vector
152
+ */
153
+ Vec4 projectOnto(const Vec4& other) const noexcept;
154
+
155
+ /**
156
+ * Reflect across a normal
157
+ */
158
+ Vec4 reflect(const Vec4& normal) const noexcept;
159
+
160
+ /**
161
+ * Check if approximately zero
162
+ */
163
+ bool isZero(float epsilon = 1e-6f) const noexcept;
164
+
165
+ /**
166
+ * Check if approximately unit length
167
+ */
168
+ bool isNormalized(float epsilon = 1e-6f) const noexcept;
169
+
170
+ /**
171
+ * Get pointer to data for GPU upload
172
+ */
173
+ const float* ptr() const noexcept { return data.data(); }
174
+ float* ptr() noexcept { return data.data(); }
175
+
176
+ // Projections (4D -> 3D)
177
+
178
+ /**
179
+ * Perspective projection: X = x*d/(d-w), Y = y*d/(d-w), Z = z*d/(d-w)
180
+ */
181
+ std::array<float, 3> projectPerspective(float distance) const noexcept;
182
+
183
+ /**
184
+ * Stereographic projection: X = x/(1-w), Y = y/(1-w), Z = z/(1-w)
185
+ */
186
+ std::array<float, 3> projectStereographic() const noexcept;
187
+
188
+ /**
189
+ * Orthographic projection: X = x, Y = y, Z = z
190
+ */
191
+ std::array<float, 3> projectOrthographic() const noexcept;
192
+ };
193
+
194
+ // Free function operators
195
+ inline Vec4 operator*(float scalar, const Vec4& v) noexcept {
196
+ return v * scalar;
197
+ }
198
+
199
+ /**
200
+ * Dot product free function
201
+ */
202
+ inline float dot(const Vec4& a, const Vec4& b) noexcept {
203
+ return a.dot(b);
204
+ }
205
+
206
+ /**
207
+ * Cross product in 4D (returns bivector, not implemented here)
208
+ * Use wedge product for proper 4D cross products
209
+ */
210
+
211
+ /**
212
+ * Distance free function
213
+ */
214
+ inline float distance(const Vec4& a, const Vec4& b) noexcept {
215
+ return a.distanceTo(b);
216
+ }
217
+
218
+ /**
219
+ * Lerp free function
220
+ */
221
+ inline Vec4 lerp(const Vec4& a, const Vec4& b, float t) noexcept {
222
+ return a.lerp(b, t);
223
+ }
224
+
225
+ } // namespace vib3