Engine prototype #13

Open
Vectornaut wants to merge 117 commits from engine-proto into main
5 changed files with 19 additions and 7 deletions
Showing only changes of commit bde42ebac0 - Show all commits

View File

@ -4,6 +4,8 @@ using Blink
using Colors using Colors
using Printf using Printf
using Main.Engine
export ConstructionViewer, display!, opentools!, closetools! export ConstructionViewer, display!, opentools!, closetools!
# === Blink utilities === # === Blink utilities ===
@ -133,7 +135,7 @@ mprod(v, w) =
function display!(viewer::ConstructionViewer, elements::Matrix) function display!(viewer::ConstructionViewer, elements::Matrix)
# load elements # load elements
elements_full = [] elements_full = []
for elt in eachcol(elements) for elt in eachcol(Engine.unmix * elements)
if mprod(elt, elt) < 0.5 if mprod(elt, elt) < 0.5
elt_full = [0; elt; fill(0, 26)] elt_full = [0; elt; fill(0, 26)]
else else
@ -206,7 +208,7 @@ end
# ~~~ sandbox setup ~~~ # ~~~ sandbox setup ~~~
# in the default view, e4 + e5 is the point at infinity # in the default view, e4 + e5 is the point at infinity
elements = sqrt(0.5) * BigFloat[ elements = Engine.nullmix * sqrt(0.5) * BigFloat[
1 1 -1 -1 0; 1 1 -1 -1 0;
1 -1 1 -1 0; 1 -1 1 -1 0;
1 -1 -1 1 0; 1 -1 -1 1 0;

View File

@ -39,11 +39,16 @@ rand_on_shell(shells::Array{<:Number}) = rand_on_shell(Random.default_rng(), she
# === elements === # === elements ===
## [temp] in light cone coordinates
point(pos) = [pos; 1; dot(pos, pos)]
## [temp] in standard coordinates
plane(normal, offset) = [normal; offset; offset] plane(normal, offset) = [normal; offset; offset]
## [temp] in standard coordinates
function sphere(center, radius) function sphere(center, radius)
dist_sq = dot(center, center) dist_sq = dot(center, center)
return [ [
center / radius; center / radius;
0.5 * ((dist_sq - 1) / radius - radius); 0.5 * ((dist_sq - 1) / radius - radius);
0.5 * ((dist_sq + 1) / radius - radius) 0.5 * ((dist_sq + 1) / radius - radius)
@ -52,8 +57,13 @@ end
# === Gram matrix realization === # === Gram matrix realization ===
# basis changes
nullmix = [Matrix{Int64}(I, 3, 3) zeros(Int64, 3, 2); zeros(Int64, 2, 3) [1 -1; 1 1]//2]
unmix = [Matrix{Int64}(I, 3, 3) zeros(Int64, 3, 2); zeros(Int64, 2, 3) [1 1; -1 1]]
# the Lorentz form # the Lorentz form
Q = diagm([1, 1, 1, 1, -1]) ## [old] Q = diagm([1, 1, 1, 1, -1])
Q = [Matrix{Int64}(I, 3, 3) zeros(Int64, 3, 2); zeros(Int64, 2, 3) [0 2; 2 0]]
# project a matrix onto the subspace of matrices whose entries vanish at the # project a matrix onto the subspace of matrices whose entries vanish at the
# given indices # given indices

View File

@ -55,7 +55,7 @@ gram = sparse(J, K, values)
## guess = Engine.rand_on_shell(fill(BigFloat(-1), 8)) ## guess = Engine.rand_on_shell(fill(BigFloat(-1), 8))
# set initial guess # set initial guess
guess = hcat( guess = Engine.nullmix * hcat(
Engine.plane(BigFloat[0, 0, 1], BigFloat(0)), Engine.plane(BigFloat[0, 0, 1], BigFloat(0)),
Engine.sphere(BigFloat[0, 0, 0], BigFloat(1//2)), Engine.sphere(BigFloat[0, 0, 0], BigFloat(1//2)),
Engine.plane(BigFloat[1, 0, 0], BigFloat(1)), Engine.plane(BigFloat[1, 0, 0], BigFloat(1)),

View File

@ -36,7 +36,7 @@ gram[1, 6] = gram[6, 1]
# in this initial guess, the mutual tangency condition is satisfied for spheres # in this initial guess, the mutual tangency condition is satisfied for spheres
# 1 through 5 # 1 through 5
Random.seed!(50793) Random.seed!(50793)
guess = hcat( guess = Engine.nullmix * hcat(
sqrt(1/BigFloat(2)) * BigFloat[ sqrt(1/BigFloat(2)) * BigFloat[
1 1 -1 -1 0; 1 1 -1 -1 0;
1 -1 1 -1 0; 1 -1 1 -1 0;

View File

@ -41,7 +41,7 @@ gram = sparse(J, K, values)
# set initial guess # set initial guess
Random.seed!(99230) Random.seed!(99230)
guess = hcat( guess = Engine.nullmix * hcat(
sqrt(1/BigFloat(3)) * BigFloat[ sqrt(1/BigFloat(3)) * BigFloat[
1 1 -1 -1 0 1 1 -1 -1 0
1 -1 1 -1 0 1 -1 1 -1 0