@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.
- package/CHANGELOG.md +36 -0
- package/DOCS/AGENT_HARNESS_ARCHITECTURE.md +243 -0
- package/DOCS/CLI_ONBOARDING.md +1 -1
- package/DOCS/CROSS_SITE_DESIGN_PATTERNS.md +117 -0
- package/DOCS/EPIC_SCROLL_EVENTS.md +773 -0
- package/DOCS/HANDOFF_LANDING_PAGE.md +154 -0
- package/DOCS/HANDOFF_SDK_DEVELOPMENT.md +493 -0
- package/DOCS/MULTIVIZ_CHOREOGRAPHY_PATTERNS.md +937 -0
- package/DOCS/PRODUCT_STRATEGY.md +63 -0
- package/DOCS/README.md +103 -0
- package/DOCS/REFERENCE_SCROLL_ANALYSIS.md +97 -0
- package/DOCS/ROADMAP.md +111 -0
- package/DOCS/SCROLL_TIMELINE_v3.md +269 -0
- package/DOCS/SITE_REFACTOR_PLAN.md +100 -0
- package/DOCS/STATUS.md +24 -0
- package/DOCS/SYSTEM_INVENTORY.md +33 -30
- package/DOCS/VISUAL_ANALYSIS_CLICKERSS.md +85 -0
- package/DOCS/VISUAL_ANALYSIS_FACETAD.md +133 -0
- package/DOCS/VISUAL_ANALYSIS_SIMONE.md +95 -0
- package/DOCS/VISUAL_ANALYSIS_TABLESIDE.md +86 -0
- package/DOCS/{BLUEPRINT_EXECUTION_PLAN_2026-01-07.md → archive/BLUEPRINT_EXECUTION_PLAN_2026-01-07.md} +1 -1
- package/DOCS/{DEV_TRACK_ANALYSIS.md → archive/DEV_TRACK_ANALYSIS.md} +3 -0
- package/DOCS/{SYSTEM_AUDIT_2026-01-30.md → archive/SYSTEM_AUDIT_2026-01-30.md} +3 -0
- package/DOCS/{DEV_TRACK_SESSION_2026-01-31.md → dev-tracks/DEV_TRACK_SESSION_2026-01-31.md} +1 -1
- package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-06.md +231 -0
- package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-13.md +127 -0
- package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-15.md +142 -0
- package/DOCS/dev-tracks/README.md +10 -0
- package/README.md +26 -13
- package/cpp/CMakeLists.txt +236 -0
- package/cpp/bindings/embind.cpp +269 -0
- package/cpp/build.sh +129 -0
- package/cpp/geometry/Crystal.cpp +103 -0
- package/cpp/geometry/Fractal.cpp +136 -0
- package/cpp/geometry/GeometryGenerator.cpp +262 -0
- package/cpp/geometry/KleinBottle.cpp +71 -0
- package/cpp/geometry/Sphere.cpp +134 -0
- package/cpp/geometry/Tesseract.cpp +94 -0
- package/cpp/geometry/Tetrahedron.cpp +83 -0
- package/cpp/geometry/Torus.cpp +65 -0
- package/cpp/geometry/WarpFunctions.cpp +238 -0
- package/cpp/geometry/Wave.cpp +85 -0
- package/cpp/include/vib3_ffi.h +238 -0
- package/cpp/math/Mat4x4.cpp +409 -0
- package/cpp/math/Mat4x4.hpp +209 -0
- package/cpp/math/Projection.cpp +142 -0
- package/cpp/math/Projection.hpp +148 -0
- package/cpp/math/Rotor4D.cpp +322 -0
- package/cpp/math/Rotor4D.hpp +204 -0
- package/cpp/math/Vec4.cpp +303 -0
- package/cpp/math/Vec4.hpp +225 -0
- package/cpp/src/vib3_ffi.cpp +607 -0
- package/cpp/tests/Geometry_test.cpp +213 -0
- package/cpp/tests/Mat4x4_test.cpp +494 -0
- package/cpp/tests/Projection_test.cpp +298 -0
- package/cpp/tests/Rotor4D_test.cpp +423 -0
- package/cpp/tests/Vec4_test.cpp +489 -0
- package/package.json +40 -27
- package/src/agent/index.js +1 -3
- package/src/agent/mcp/MCPServer.js +918 -0
- package/src/agent/mcp/index.js +1 -1
- package/src/agent/mcp/stdio-server.js +264 -0
- package/src/agent/mcp/tools.js +454 -0
- package/src/cli/index.js +374 -44
- package/src/core/CanvasManager.js +97 -204
- package/src/core/ErrorReporter.js +1 -1
- package/src/core/Parameters.js +1 -1
- package/src/core/VIB3Engine.js +93 -4
- package/src/core/VitalitySystem.js +53 -0
- package/src/core/index.js +18 -0
- package/src/core/renderers/FacetedRendererAdapter.js +10 -9
- package/src/core/renderers/HolographicRendererAdapter.js +13 -9
- package/src/core/renderers/QuantumRendererAdapter.js +11 -7
- package/src/creative/AestheticMapper.js +628 -0
- package/src/creative/ChoreographyPlayer.js +481 -0
- package/src/creative/index.js +11 -0
- package/src/export/TradingCardManager.js +3 -4
- package/src/export/index.js +11 -1
- package/src/faceted/FacetedSystem.js +241 -388
- package/src/holograms/HolographicVisualizer.js +29 -12
- package/src/holograms/RealHolographicSystem.js +194 -43
- package/src/math/index.js +7 -7
- package/src/polychora/PolychoraSystem.js +77 -0
- package/src/quantum/QuantumEngine.js +103 -66
- package/src/quantum/QuantumVisualizer.js +7 -2
- package/src/reactivity/index.js +3 -5
- package/src/render/LayerPresetManager.js +372 -0
- package/src/render/LayerReactivityBridge.js +344 -0
- package/src/render/LayerRelationshipGraph.js +610 -0
- package/src/render/MultiCanvasBridge.js +148 -25
- package/src/render/UnifiedRenderBridge.js +3 -0
- package/src/render/index.js +27 -2
- package/src/scene/index.js +4 -4
- package/src/shaders/faceted/faceted.frag.glsl +220 -80
- package/src/shaders/faceted/faceted.frag.wgsl +138 -97
- package/src/shaders/holographic/holographic.frag.glsl +28 -9
- package/src/shaders/holographic/holographic.frag.wgsl +107 -38
- package/src/shaders/quantum/quantum.frag.glsl +1 -0
- package/src/shaders/quantum/quantum.frag.wgsl +1 -1
- package/src/testing/ParallelTestFramework.js +2 -2
- package/src/viewer/GalleryUI.js +17 -0
- package/src/viewer/ViewerPortal.js +2 -2
- package/src/viewer/index.js +1 -1
- package/tools/headless-renderer.js +258 -0
- package/tools/shader-sync-verify.js +8 -4
- package/tools/site-analysis/all-reports.json +32 -0
- package/tools/site-analysis/combined-analysis.md +50 -0
- package/tools/site-analyzer.mjs +779 -0
- package/tools/visual-catalog/capture.js +276 -0
- package/tools/visual-catalog/composite.js +138 -0
- package/types/adaptive-sdk.d.ts +204 -5
- package/types/agent/cli.d.ts +78 -0
- package/types/agent/index.d.ts +18 -0
- package/types/agent/mcp.d.ts +87 -0
- package/types/agent/telemetry.d.ts +190 -0
- package/types/core/VIB3Engine.d.ts +26 -0
- package/types/core/index.d.ts +261 -0
- package/types/creative/AestheticMapper.d.ts +72 -0
- package/types/creative/ChoreographyPlayer.d.ts +96 -0
- package/types/creative/index.d.ts +17 -0
- package/types/export/index.d.ts +243 -0
- package/types/geometry/index.d.ts +164 -0
- package/types/math/index.d.ts +214 -0
- package/types/render/LayerPresetManager.d.ts +78 -0
- package/types/render/LayerReactivityBridge.d.ts +85 -0
- package/types/render/LayerRelationshipGraph.d.ts +174 -0
- package/types/render/index.d.ts +3 -0
- package/types/scene/index.d.ts +204 -0
- package/types/systems/index.d.ts +244 -0
- package/types/variations/index.d.ts +62 -0
- package/types/viewer/index.d.ts +225 -0
- /package/DOCS/{DEV_TRACK_PLAN_2026-01-07.md → archive/DEV_TRACK_PLAN_2026-01-07.md} +0 -0
- /package/DOCS/{SESSION_014_PLAN.md → archive/SESSION_014_PLAN.md} +0 -0
- /package/DOCS/{SESSION_LOG_2026-01-07.md → archive/SESSION_LOG_2026-01-07.md} +0 -0
- /package/DOCS/{STRATEGIC_BLUEPRINT_2026-01-07.md → archive/STRATEGIC_BLUEPRINT_2026-01-07.md} +0 -0
- /package/src/viewer/{ReactivityManager.js → ViewerInputHandler.js} +0 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sphere.cpp - 3-Sphere (S3) Surface Points
|
|
3
|
+
*
|
|
4
|
+
* Generates points on the 3-sphere (hypersphere) in 4D using
|
|
5
|
+
* Hopf coordinates (psi, theta, phi) parametrization.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#include "math/Vec4.hpp"
|
|
9
|
+
#include <vector>
|
|
10
|
+
#include <cmath>
|
|
11
|
+
#include <numbers>
|
|
12
|
+
|
|
13
|
+
namespace vib3 {
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Generate points on S3 using Hopf coordinate parametrization.
|
|
17
|
+
*
|
|
18
|
+
* The 3-sphere is parametrized by three angles:
|
|
19
|
+
* x = cos(psi) * cos(theta)
|
|
20
|
+
* y = cos(psi) * sin(theta)
|
|
21
|
+
* z = sin(psi) * cos(phi)
|
|
22
|
+
* w = sin(psi) * sin(phi)
|
|
23
|
+
*
|
|
24
|
+
* where psi in [0, pi/2], theta in [0, 2pi), phi in [0, 2pi).
|
|
25
|
+
*
|
|
26
|
+
* @param resolution Controls sampling density. Total points = resolution^2 * resolution/2
|
|
27
|
+
* @return Vector of 4D points on the unit 3-sphere
|
|
28
|
+
*/
|
|
29
|
+
std::vector<Vec4> generateSphere(int resolution) noexcept {
|
|
30
|
+
if (resolution < 4) resolution = 4;
|
|
31
|
+
|
|
32
|
+
constexpr float pi = std::numbers::pi_v<float>;
|
|
33
|
+
constexpr float twoPi = 2.0f * std::numbers::pi_v<float>;
|
|
34
|
+
constexpr float halfPi = std::numbers::pi_v<float> / 2.0f;
|
|
35
|
+
|
|
36
|
+
// Number of steps for each angle
|
|
37
|
+
int psiSteps = resolution / 2;
|
|
38
|
+
int thetaSteps = resolution;
|
|
39
|
+
int phiSteps = resolution;
|
|
40
|
+
|
|
41
|
+
if (psiSteps < 2) psiSteps = 2;
|
|
42
|
+
|
|
43
|
+
std::vector<Vec4> vertices;
|
|
44
|
+
vertices.reserve(static_cast<size_t>(psiSteps) *
|
|
45
|
+
static_cast<size_t>(thetaSteps) *
|
|
46
|
+
static_cast<size_t>(phiSteps));
|
|
47
|
+
|
|
48
|
+
for (int ip = 0; ip < psiSteps; ++ip) {
|
|
49
|
+
float psi = halfPi * static_cast<float>(ip) / static_cast<float>(psiSteps - 1);
|
|
50
|
+
float cosPsi = std::cos(psi);
|
|
51
|
+
float sinPsi = std::sin(psi);
|
|
52
|
+
|
|
53
|
+
for (int it = 0; it < thetaSteps; ++it) {
|
|
54
|
+
float theta = twoPi * static_cast<float>(it) / static_cast<float>(thetaSteps);
|
|
55
|
+
float cosTheta = std::cos(theta);
|
|
56
|
+
float sinTheta = std::sin(theta);
|
|
57
|
+
|
|
58
|
+
for (int iphi = 0; iphi < phiSteps; ++iphi) {
|
|
59
|
+
float phi = twoPi * static_cast<float>(iphi) / static_cast<float>(phiSteps);
|
|
60
|
+
float cosPhi = std::cos(phi);
|
|
61
|
+
float sinPhi = std::sin(phi);
|
|
62
|
+
|
|
63
|
+
vertices.emplace_back(
|
|
64
|
+
cosPsi * cosTheta,
|
|
65
|
+
cosPsi * sinTheta,
|
|
66
|
+
sinPsi * cosPhi,
|
|
67
|
+
sinPsi * sinPhi
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return vertices;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Generate points on S3 using the Hopf fibration structure.
|
|
78
|
+
*
|
|
79
|
+
* The Hopf fibration maps S3 -> S2, with each fiber being a great circle.
|
|
80
|
+
* This produces points organized along Hopf fibers, useful for
|
|
81
|
+
* visualizing the fibration structure.
|
|
82
|
+
*
|
|
83
|
+
* @param numFibers Number of base points on S2
|
|
84
|
+
* @param pointsPerFiber Number of points along each Hopf circle
|
|
85
|
+
* @return Vector of 4D points on the unit 3-sphere
|
|
86
|
+
*/
|
|
87
|
+
std::vector<Vec4> generateHopfFibration(int numFibers, int pointsPerFiber) noexcept {
|
|
88
|
+
if (numFibers < 4) numFibers = 4;
|
|
89
|
+
if (pointsPerFiber < 8) pointsPerFiber = 8;
|
|
90
|
+
|
|
91
|
+
constexpr float pi = std::numbers::pi_v<float>;
|
|
92
|
+
constexpr float twoPi = 2.0f * std::numbers::pi_v<float>;
|
|
93
|
+
|
|
94
|
+
// Distribute base points on S2 using a spiral
|
|
95
|
+
int sqrtFibers = static_cast<int>(std::sqrt(static_cast<float>(numFibers)));
|
|
96
|
+
if (sqrtFibers < 2) sqrtFibers = 2;
|
|
97
|
+
|
|
98
|
+
std::vector<Vec4> vertices;
|
|
99
|
+
vertices.reserve(static_cast<size_t>(numFibers) * static_cast<size_t>(pointsPerFiber));
|
|
100
|
+
|
|
101
|
+
for (int fi = 0; fi < sqrtFibers; ++fi) {
|
|
102
|
+
float baseTheta = pi * static_cast<float>(fi) / static_cast<float>(sqrtFibers - 1);
|
|
103
|
+
|
|
104
|
+
for (int fj = 0; fj < sqrtFibers; ++fj) {
|
|
105
|
+
float basePhi = twoPi * static_cast<float>(fj) / static_cast<float>(sqrtFibers);
|
|
106
|
+
|
|
107
|
+
// Base point on S2
|
|
108
|
+
float halfTheta = baseTheta * 0.5f;
|
|
109
|
+
float cosHalf = std::cos(halfTheta);
|
|
110
|
+
float sinHalf = std::sin(halfTheta);
|
|
111
|
+
|
|
112
|
+
// Trace the Hopf fiber (great circle in S3) for this base point
|
|
113
|
+
for (int p = 0; p < pointsPerFiber; ++p) {
|
|
114
|
+
float t = twoPi * static_cast<float>(p) / static_cast<float>(pointsPerFiber);
|
|
115
|
+
|
|
116
|
+
float cosT = std::cos(t);
|
|
117
|
+
float sinT = std::sin(t);
|
|
118
|
+
float cosBP = std::cos(basePhi + t);
|
|
119
|
+
float sinBP = std::sin(basePhi + t);
|
|
120
|
+
|
|
121
|
+
vertices.emplace_back(
|
|
122
|
+
cosHalf * cosT,
|
|
123
|
+
cosHalf * sinT,
|
|
124
|
+
sinHalf * cosBP,
|
|
125
|
+
sinHalf * sinBP
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return vertices;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
} // namespace vib3
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tesseract.cpp - 4D Hypercube Geometry
|
|
3
|
+
*
|
|
4
|
+
* Generates the 16 vertices and 32 edges of a tesseract (4D cube).
|
|
5
|
+
* Vertices are at all combinations of (+-1, +-1, +-1, +-1).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#include "math/Vec4.hpp"
|
|
9
|
+
#include <vector>
|
|
10
|
+
#include <cstdint>
|
|
11
|
+
|
|
12
|
+
namespace vib3 {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Generate the 16 vertices of a tesseract.
|
|
16
|
+
*
|
|
17
|
+
* A tesseract has vertices at every combination of (+-1, +-1, +-1, +-1).
|
|
18
|
+
*/
|
|
19
|
+
std::vector<Vec4> generateTesseractVertices() noexcept {
|
|
20
|
+
std::vector<Vec4> vertices;
|
|
21
|
+
vertices.reserve(16);
|
|
22
|
+
|
|
23
|
+
for (uint8_t i = 0; i < 16; ++i) {
|
|
24
|
+
float x = (i & 1) ? 1.0f : -1.0f;
|
|
25
|
+
float y = (i & 2) ? 1.0f : -1.0f;
|
|
26
|
+
float z = (i & 4) ? 1.0f : -1.0f;
|
|
27
|
+
float w = (i & 8) ? 1.0f : -1.0f;
|
|
28
|
+
vertices.emplace_back(x, y, z, w);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return vertices;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Edge pair for a tesseract (indices into vertex array).
|
|
36
|
+
*/
|
|
37
|
+
struct Edge {
|
|
38
|
+
int a, b;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Generate the 32 edges of a tesseract.
|
|
43
|
+
*
|
|
44
|
+
* Two vertices share an edge if and only if they differ in exactly one coordinate.
|
|
45
|
+
*/
|
|
46
|
+
std::vector<Edge> generateTesseractEdges() noexcept {
|
|
47
|
+
std::vector<Edge> edges;
|
|
48
|
+
edges.reserve(32);
|
|
49
|
+
|
|
50
|
+
for (int i = 0; i < 16; ++i) {
|
|
51
|
+
for (int bit = 0; bit < 4; ++bit) {
|
|
52
|
+
int j = i ^ (1 << bit);
|
|
53
|
+
if (j > i) {
|
|
54
|
+
edges.push_back({i, j});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return edges;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Generate tesseract geometry with edge interpolation.
|
|
64
|
+
*
|
|
65
|
+
* Returns vertices along all edges, creating a wireframe mesh.
|
|
66
|
+
* Each edge is subdivided into `resolution` segments, generating
|
|
67
|
+
* intermediate points via linear interpolation.
|
|
68
|
+
*
|
|
69
|
+
* @param resolution Number of subdivisions per edge (minimum 2)
|
|
70
|
+
* @return Vector of 4D points along all tesseract edges
|
|
71
|
+
*/
|
|
72
|
+
std::vector<Vec4> generateTesseract(int resolution) noexcept {
|
|
73
|
+
if (resolution < 2) resolution = 2;
|
|
74
|
+
|
|
75
|
+
auto baseVertices = generateTesseractVertices();
|
|
76
|
+
auto edges = generateTesseractEdges();
|
|
77
|
+
|
|
78
|
+
std::vector<Vec4> vertices;
|
|
79
|
+
vertices.reserve(static_cast<size_t>(edges.size()) * static_cast<size_t>(resolution));
|
|
80
|
+
|
|
81
|
+
for (const auto& edge : edges) {
|
|
82
|
+
const Vec4& a = baseVertices[static_cast<size_t>(edge.a)];
|
|
83
|
+
const Vec4& b = baseVertices[static_cast<size_t>(edge.b)];
|
|
84
|
+
|
|
85
|
+
for (int i = 0; i < resolution; ++i) {
|
|
86
|
+
float t = static_cast<float>(i) / static_cast<float>(resolution - 1);
|
|
87
|
+
vertices.push_back(a.lerp(b, t));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return vertices;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
} // namespace vib3
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tetrahedron.cpp - 3D Simplex Embedded in 4D
|
|
3
|
+
*
|
|
4
|
+
* Generates vertices and edge geometry for a regular tetrahedron
|
|
5
|
+
* embedded in 4D space (w = 0).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#include "math/Vec4.hpp"
|
|
9
|
+
#include <vector>
|
|
10
|
+
#include <cmath>
|
|
11
|
+
#include <numbers>
|
|
12
|
+
|
|
13
|
+
namespace vib3 {
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Generate the 4 vertices of a regular tetrahedron in 4D.
|
|
17
|
+
*
|
|
18
|
+
* The tetrahedron is centered at the origin with unit edge length,
|
|
19
|
+
* embedded in the w=0 hyperplane. Vertices are placed so that the
|
|
20
|
+
* centroid lies at the origin.
|
|
21
|
+
*/
|
|
22
|
+
std::vector<Vec4> generateTetrahedronVertices() noexcept {
|
|
23
|
+
// Regular tetrahedron vertices centered at origin
|
|
24
|
+
// Using the standard construction: one vertex up, three forming
|
|
25
|
+
// an equilateral triangle below.
|
|
26
|
+
constexpr float a = 1.0f;
|
|
27
|
+
const float h = a * std::sqrt(2.0f / 3.0f);
|
|
28
|
+
const float r = a / std::sqrt(3.0f);
|
|
29
|
+
|
|
30
|
+
// Vertical offset to center at origin
|
|
31
|
+
const float yOff = -h / 4.0f;
|
|
32
|
+
|
|
33
|
+
std::vector<Vec4> vertices;
|
|
34
|
+
vertices.reserve(4);
|
|
35
|
+
|
|
36
|
+
// Top vertex
|
|
37
|
+
vertices.emplace_back(0.0f, 3.0f * h / 4.0f + yOff, 0.0f, 0.0f);
|
|
38
|
+
|
|
39
|
+
// Bottom triangle
|
|
40
|
+
vertices.emplace_back(0.0f, yOff, r, 0.0f);
|
|
41
|
+
vertices.emplace_back(-r * std::sqrt(3.0f) / 2.0f, yOff, -r / 2.0f, 0.0f);
|
|
42
|
+
vertices.emplace_back( r * std::sqrt(3.0f) / 2.0f, yOff, -r / 2.0f, 0.0f);
|
|
43
|
+
|
|
44
|
+
return vertices;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Generate tetrahedron geometry with edge interpolation.
|
|
49
|
+
*
|
|
50
|
+
* Subdivides each of the 6 edges into `resolution` segments and
|
|
51
|
+
* returns all interpolated points.
|
|
52
|
+
*
|
|
53
|
+
* @param resolution Number of subdivisions per edge (minimum 2)
|
|
54
|
+
* @return Vector of 4D points along all tetrahedron edges
|
|
55
|
+
*/
|
|
56
|
+
std::vector<Vec4> generateTetrahedron(int resolution) noexcept {
|
|
57
|
+
if (resolution < 2) resolution = 2;
|
|
58
|
+
|
|
59
|
+
auto baseVertices = generateTetrahedronVertices();
|
|
60
|
+
|
|
61
|
+
// 6 edges for a tetrahedron: every pair of 4 vertices
|
|
62
|
+
constexpr int edgePairs[6][2] = {
|
|
63
|
+
{0, 1}, {0, 2}, {0, 3},
|
|
64
|
+
{1, 2}, {1, 3}, {2, 3}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
std::vector<Vec4> vertices;
|
|
68
|
+
vertices.reserve(6 * static_cast<size_t>(resolution));
|
|
69
|
+
|
|
70
|
+
for (const auto& pair : edgePairs) {
|
|
71
|
+
const Vec4& a = baseVertices[static_cast<size_t>(pair[0])];
|
|
72
|
+
const Vec4& b = baseVertices[static_cast<size_t>(pair[1])];
|
|
73
|
+
|
|
74
|
+
for (int i = 0; i < resolution; ++i) {
|
|
75
|
+
float t = static_cast<float>(i) / static_cast<float>(resolution - 1);
|
|
76
|
+
vertices.push_back(a.lerp(b, t));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return vertices;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
} // namespace vib3
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Torus.cpp - Clifford Torus in 4D
|
|
3
|
+
*
|
|
4
|
+
* Generates points on the Clifford torus, which is the product of
|
|
5
|
+
* two circles embedded in 4D: S1 x S1 in R4.
|
|
6
|
+
*
|
|
7
|
+
* The Clifford torus is a flat torus that lies on the 3-sphere S3.
|
|
8
|
+
* Parametrization:
|
|
9
|
+
* x = cos(u) * r1
|
|
10
|
+
* y = sin(u) * r1
|
|
11
|
+
* z = cos(v) * r2
|
|
12
|
+
* w = sin(v) * r2
|
|
13
|
+
* where r1^2 + r2^2 = 1 for it to lie on S3 (r1 = r2 = 1/sqrt(2)).
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
#include "math/Vec4.hpp"
|
|
17
|
+
#include <vector>
|
|
18
|
+
#include <cmath>
|
|
19
|
+
#include <numbers>
|
|
20
|
+
|
|
21
|
+
namespace vib3 {
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Generate the Clifford torus in 4D.
|
|
25
|
+
*
|
|
26
|
+
* Uses the standard parametrization with equal radii r1 = r2 = 1/sqrt(2),
|
|
27
|
+
* which places the torus on the unit 3-sphere. The two angles u and v
|
|
28
|
+
* each range over [0, 2*pi).
|
|
29
|
+
*
|
|
30
|
+
* @param resolution Number of subdivisions for each angle (total points = resolution^2)
|
|
31
|
+
* @return Vector of 4D points on the Clifford torus
|
|
32
|
+
*/
|
|
33
|
+
std::vector<Vec4> generateTorus(int resolution) noexcept {
|
|
34
|
+
if (resolution < 4) resolution = 4;
|
|
35
|
+
|
|
36
|
+
constexpr float twoPi = 2.0f * std::numbers::pi_v<float>;
|
|
37
|
+
// Equal radii for Clifford torus on S3
|
|
38
|
+
constexpr float r = 1.0f / std::numbers::sqrt2_v<float>;
|
|
39
|
+
|
|
40
|
+
std::vector<Vec4> vertices;
|
|
41
|
+
vertices.reserve(static_cast<size_t>(resolution) * static_cast<size_t>(resolution));
|
|
42
|
+
|
|
43
|
+
for (int iu = 0; iu < resolution; ++iu) {
|
|
44
|
+
float u = twoPi * static_cast<float>(iu) / static_cast<float>(resolution);
|
|
45
|
+
float cosU = std::cos(u);
|
|
46
|
+
float sinU = std::sin(u);
|
|
47
|
+
|
|
48
|
+
for (int iv = 0; iv < resolution; ++iv) {
|
|
49
|
+
float v = twoPi * static_cast<float>(iv) / static_cast<float>(resolution);
|
|
50
|
+
float cosV = std::cos(v);
|
|
51
|
+
float sinV = std::sin(v);
|
|
52
|
+
|
|
53
|
+
vertices.emplace_back(
|
|
54
|
+
r * cosU,
|
|
55
|
+
r * sinU,
|
|
56
|
+
r * cosV,
|
|
57
|
+
r * sinV
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return vertices;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
} // namespace vib3
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WarpFunctions.cpp - Core Type Warp Functions
|
|
3
|
+
*
|
|
4
|
+
* Provides warp transformations that modify base geometries to create
|
|
5
|
+
* the three core type variants (Base, Hypersphere, Hypertetrahedron).
|
|
6
|
+
*
|
|
7
|
+
* Core type 0 (Base, index 0-7): No warp, pure base geometry.
|
|
8
|
+
* Core type 1 (Hypersphere, 8-15): Project onto 3-sphere surface.
|
|
9
|
+
* Core type 2 (Hypertetra, 16-23): Warp toward pentatope vertices.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
#include "math/Vec4.hpp"
|
|
13
|
+
#include <vector>
|
|
14
|
+
#include <cmath>
|
|
15
|
+
#include <numbers>
|
|
16
|
+
#include <algorithm>
|
|
17
|
+
|
|
18
|
+
namespace vib3 {
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Project a 4D point onto the 3-sphere of given radius.
|
|
22
|
+
*
|
|
23
|
+
* Normalizes the point to lie on S3, then scales by `radius`.
|
|
24
|
+
* If the point is at the origin, returns a default point on the sphere.
|
|
25
|
+
*
|
|
26
|
+
* @param point Input 4D point
|
|
27
|
+
* @param radius Radius of the target 3-sphere
|
|
28
|
+
* @return Point projected onto S3 * radius
|
|
29
|
+
*/
|
|
30
|
+
Vec4 warpHypersphere(Vec4 point, float radius) noexcept {
|
|
31
|
+
float len = point.length();
|
|
32
|
+
|
|
33
|
+
if (len < 1e-8f) {
|
|
34
|
+
// Degenerate case: return a default point on the sphere
|
|
35
|
+
return Vec4(radius, 0.0f, 0.0f, 0.0f);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return point * (radius / len);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Inverse stereographic projection from R3 to S3.
|
|
43
|
+
*
|
|
44
|
+
* Maps a 3D point (interpreted as x,y,z with w=0) onto the 3-sphere
|
|
45
|
+
* using inverse stereographic projection from the north pole (0,0,0,1).
|
|
46
|
+
*
|
|
47
|
+
* @param point Input 4D point (only x,y,z used)
|
|
48
|
+
* @return Point on unit S3
|
|
49
|
+
*/
|
|
50
|
+
Vec4 inverseStereographicToHypersphere(Vec4 point) noexcept {
|
|
51
|
+
float r2 = point.x * point.x + point.y * point.y + point.z * point.z;
|
|
52
|
+
float denom = 1.0f + r2;
|
|
53
|
+
|
|
54
|
+
return Vec4(
|
|
55
|
+
2.0f * point.x / denom,
|
|
56
|
+
2.0f * point.y / denom,
|
|
57
|
+
2.0f * point.z / denom,
|
|
58
|
+
(r2 - 1.0f) / denom
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Apply Hopf fibration mapping.
|
|
64
|
+
*
|
|
65
|
+
* Given a point on S3, returns its base point on S2 (the Hopf projection)
|
|
66
|
+
* and the fiber angle. This is used to visualize toroidal structures
|
|
67
|
+
* inherent in the 3-sphere.
|
|
68
|
+
*
|
|
69
|
+
* @param point Point on S3
|
|
70
|
+
* @return Projected point (x,y,z = S2 base point, w = fiber angle)
|
|
71
|
+
*/
|
|
72
|
+
Vec4 hopfProject(Vec4 point) noexcept {
|
|
73
|
+
// Normalize to ensure on S3
|
|
74
|
+
Vec4 p = point.normalized();
|
|
75
|
+
|
|
76
|
+
// Hopf map S3 -> S2:
|
|
77
|
+
// n1 = 2(x*z + y*w)
|
|
78
|
+
// n2 = 2(y*z - x*w)
|
|
79
|
+
// n3 = x^2 + y^2 - z^2 - w^2
|
|
80
|
+
float n1 = 2.0f * (p.x * p.z + p.y * p.w);
|
|
81
|
+
float n2 = 2.0f * (p.y * p.z - p.x * p.w);
|
|
82
|
+
float n3 = p.x * p.x + p.y * p.y - p.z * p.z - p.w * p.w;
|
|
83
|
+
|
|
84
|
+
// Fiber angle
|
|
85
|
+
float fiberAngle = std::atan2(p.y, p.x) - std::atan2(p.w, p.z);
|
|
86
|
+
|
|
87
|
+
return Vec4(n1, n2, n3, fiberAngle);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Batch warp: project all points in a geometry onto S3.
|
|
92
|
+
*
|
|
93
|
+
* @param points Input geometry vertices
|
|
94
|
+
* @param radius Radius of the target 3-sphere
|
|
95
|
+
* @return Warped vertices on the 3-sphere
|
|
96
|
+
*/
|
|
97
|
+
std::vector<Vec4> warpHypersphereBatch(const std::vector<Vec4>& points,
|
|
98
|
+
float radius) noexcept {
|
|
99
|
+
std::vector<Vec4> result;
|
|
100
|
+
result.reserve(points.size());
|
|
101
|
+
|
|
102
|
+
for (const auto& p : points) {
|
|
103
|
+
result.push_back(warpHypersphere(p, radius));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// ---- Hypertetrahedron (Pentatope) Warp ----
|
|
110
|
+
|
|
111
|
+
namespace {
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The 5 vertices of a regular 5-cell (pentatope) in R4.
|
|
115
|
+
*
|
|
116
|
+
* These are the vertices of the simplest regular 4D polytope,
|
|
117
|
+
* the analogue of the tetrahedron in 4D.
|
|
118
|
+
*/
|
|
119
|
+
constexpr int kPentatopeVertexCount = 5;
|
|
120
|
+
|
|
121
|
+
Vec4 getPentatopeVertex(int index) noexcept {
|
|
122
|
+
// Standard regular 5-cell vertices
|
|
123
|
+
// Constructed so that all pairwise distances are equal.
|
|
124
|
+
const float s = std::sqrt(2.0f / 5.0f);
|
|
125
|
+
const float t = std::sqrt(2.0f / 3.0f);
|
|
126
|
+
const float u = 1.0f / std::sqrt(3.0f);
|
|
127
|
+
const float v = 1.0f / std::sqrt(15.0f);
|
|
128
|
+
|
|
129
|
+
switch (index) {
|
|
130
|
+
case 0: return Vec4( t, 0.0f, 0.0f, -v);
|
|
131
|
+
case 1: return Vec4(-u, u, 0.0f, -v);
|
|
132
|
+
case 2: return Vec4(-u, -u, 0.0f, -v);
|
|
133
|
+
case 3: return Vec4( 0.0f, 0.0f, t, -v);
|
|
134
|
+
case 4: return Vec4( 0.0f, 0.0f, 0.0f, 4.0f * v);
|
|
135
|
+
default: return Vec4::zero();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
} // anonymous namespace
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Warp a 4D point toward the nearest pentatope vertex.
|
|
143
|
+
*
|
|
144
|
+
* Finds the closest vertex of the regular 5-cell and interpolates
|
|
145
|
+
* the point toward it, creating a tetrahedral clustering effect.
|
|
146
|
+
* The interpolation factor is based on the inverse distance to
|
|
147
|
+
* the nearest vertex, producing a gravitational pull effect.
|
|
148
|
+
*
|
|
149
|
+
* @param point Input 4D point
|
|
150
|
+
* @return Warped point attracted toward nearest pentatope vertex
|
|
151
|
+
*/
|
|
152
|
+
Vec4 warpHypertetra(Vec4 point) noexcept {
|
|
153
|
+
// Find nearest pentatope vertex
|
|
154
|
+
int nearestIdx = 0;
|
|
155
|
+
float nearestDist = point.distanceSquaredTo(getPentatopeVertex(0));
|
|
156
|
+
|
|
157
|
+
for (int i = 1; i < kPentatopeVertexCount; ++i) {
|
|
158
|
+
float dist = point.distanceSquaredTo(getPentatopeVertex(i));
|
|
159
|
+
if (dist < nearestDist) {
|
|
160
|
+
nearestDist = dist;
|
|
161
|
+
nearestIdx = i;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
Vec4 nearest = getPentatopeVertex(nearestIdx);
|
|
166
|
+
|
|
167
|
+
// Warp factor based on distance (closer = stronger pull)
|
|
168
|
+
float dist = std::sqrt(nearestDist);
|
|
169
|
+
float warpStrength = 1.0f / (1.0f + dist * 2.0f);
|
|
170
|
+
|
|
171
|
+
// Interpolate toward the nearest pentatope vertex
|
|
172
|
+
return point.lerp(nearest, warpStrength);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Warp a 4D point onto the edges of the pentatope.
|
|
177
|
+
*
|
|
178
|
+
* Projects the point to the nearest edge of the 5-cell,
|
|
179
|
+
* producing a skeletal wireframe appearance.
|
|
180
|
+
*
|
|
181
|
+
* @param point Input 4D point
|
|
182
|
+
* @return Point projected onto nearest pentatope edge
|
|
183
|
+
*/
|
|
184
|
+
Vec4 warpToEdges(Vec4 point) noexcept {
|
|
185
|
+
// 10 edges of the pentatope (all pairs of 5 vertices)
|
|
186
|
+
constexpr int edgePairs[10][2] = {
|
|
187
|
+
{0, 1}, {0, 2}, {0, 3}, {0, 4},
|
|
188
|
+
{1, 2}, {1, 3}, {1, 4},
|
|
189
|
+
{2, 3}, {2, 4},
|
|
190
|
+
{3, 4}
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
Vec4 bestProjection = point;
|
|
194
|
+
float bestDist = 1e10f;
|
|
195
|
+
|
|
196
|
+
for (const auto& pair : edgePairs) {
|
|
197
|
+
Vec4 a = getPentatopeVertex(pair[0]);
|
|
198
|
+
Vec4 b = getPentatopeVertex(pair[1]);
|
|
199
|
+
Vec4 edge = b - a;
|
|
200
|
+
Vec4 toPoint = point - a;
|
|
201
|
+
|
|
202
|
+
// Project onto edge (clamped to [0,1])
|
|
203
|
+
float edgeLenSq = edge.dot(edge);
|
|
204
|
+
if (edgeLenSq < 1e-10f) continue;
|
|
205
|
+
|
|
206
|
+
float t = toPoint.dot(edge) / edgeLenSq;
|
|
207
|
+
t = std::max(0.0f, std::min(1.0f, t));
|
|
208
|
+
|
|
209
|
+
Vec4 projected = a.lerp(b, t);
|
|
210
|
+
float dist = point.distanceSquaredTo(projected);
|
|
211
|
+
|
|
212
|
+
if (dist < bestDist) {
|
|
213
|
+
bestDist = dist;
|
|
214
|
+
bestProjection = projected;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return bestProjection;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Batch warp: apply hypertetra warp to all points.
|
|
223
|
+
*
|
|
224
|
+
* @param points Input geometry vertices
|
|
225
|
+
* @return Warped vertices attracted toward pentatope vertices
|
|
226
|
+
*/
|
|
227
|
+
std::vector<Vec4> warpHypertetraBatch(const std::vector<Vec4>& points) noexcept {
|
|
228
|
+
std::vector<Vec4> result;
|
|
229
|
+
result.reserve(points.size());
|
|
230
|
+
|
|
231
|
+
for (const auto& p : points) {
|
|
232
|
+
result.push_back(warpHypertetra(p));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return result;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
} // namespace vib3
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wave.cpp - Sinusoidal Interference Pattern in 4D
|
|
3
|
+
*
|
|
4
|
+
* Generates a grid of 4D points with sinusoidal wave displacement.
|
|
5
|
+
* The base grid lies in the XZ plane, with Y and W components driven
|
|
6
|
+
* by interference of multiple wave sources.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#include "math/Vec4.hpp"
|
|
10
|
+
#include <vector>
|
|
11
|
+
#include <cmath>
|
|
12
|
+
#include <numbers>
|
|
13
|
+
|
|
14
|
+
namespace vib3 {
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Generate a 4D sinusoidal interference pattern.
|
|
18
|
+
*
|
|
19
|
+
* Creates a resolution x resolution grid in the XZ plane, centered at
|
|
20
|
+
* the origin. The Y component is displaced by the sum of three wave
|
|
21
|
+
* sources with different frequencies, and the W component uses a
|
|
22
|
+
* cross-wave pattern, producing a rich 4D interference field.
|
|
23
|
+
*
|
|
24
|
+
* @param resolution Number of grid points along each axis (total = resolution^2)
|
|
25
|
+
* @return Vector of 4D points with wave displacement
|
|
26
|
+
*/
|
|
27
|
+
std::vector<Vec4> generateWave(int resolution) noexcept {
|
|
28
|
+
if (resolution < 4) resolution = 4;
|
|
29
|
+
|
|
30
|
+
constexpr float pi = std::numbers::pi_v<float>;
|
|
31
|
+
|
|
32
|
+
// Grid extends from -gridExtent to +gridExtent
|
|
33
|
+
constexpr float gridExtent = 2.0f;
|
|
34
|
+
|
|
35
|
+
// Wave parameters: {frequency, amplitude, phase offset X, phase offset Z}
|
|
36
|
+
struct WaveSource {
|
|
37
|
+
float freq;
|
|
38
|
+
float ampY;
|
|
39
|
+
float ampW;
|
|
40
|
+
float phaseX;
|
|
41
|
+
float phaseZ;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
constexpr WaveSource waves[] = {
|
|
45
|
+
{ 1.0f, 0.5f, 0.3f, 0.0f, 0.0f }, // Primary wave
|
|
46
|
+
{ 2.3f, 0.25f, 0.15f, pi * 0.5f, pi * 0.25f }, // Secondary wave
|
|
47
|
+
{ 3.7f, 0.125f, 0.1f, pi * 0.75f, pi * 0.6f }, // Tertiary wave
|
|
48
|
+
};
|
|
49
|
+
constexpr int numWaves = 3;
|
|
50
|
+
|
|
51
|
+
std::vector<Vec4> vertices;
|
|
52
|
+
vertices.reserve(static_cast<size_t>(resolution) * static_cast<size_t>(resolution));
|
|
53
|
+
|
|
54
|
+
float step = (2.0f * gridExtent) / static_cast<float>(resolution - 1);
|
|
55
|
+
|
|
56
|
+
for (int ix = 0; ix < resolution; ++ix) {
|
|
57
|
+
float x = -gridExtent + static_cast<float>(ix) * step;
|
|
58
|
+
|
|
59
|
+
for (int iz = 0; iz < resolution; ++iz) {
|
|
60
|
+
float z = -gridExtent + static_cast<float>(iz) * step;
|
|
61
|
+
|
|
62
|
+
float y = 0.0f;
|
|
63
|
+
float w = 0.0f;
|
|
64
|
+
|
|
65
|
+
// Sum contributions from all wave sources
|
|
66
|
+
for (int wi = 0; wi < numWaves; ++wi) {
|
|
67
|
+
const auto& ws = waves[wi];
|
|
68
|
+
float phX = ws.freq * x * pi + ws.phaseX;
|
|
69
|
+
float phZ = ws.freq * z * pi + ws.phaseZ;
|
|
70
|
+
|
|
71
|
+
// Y displacement: circular wave pattern
|
|
72
|
+
y += ws.ampY * std::sin(phX) * std::cos(phZ);
|
|
73
|
+
|
|
74
|
+
// W displacement: cross-interference pattern
|
|
75
|
+
w += ws.ampW * std::cos(phX + phZ);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
vertices.emplace_back(x, y, z, w);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return vertices;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
} // namespace vib3
|