From 59a527af43b869da239a4c3789a52dea52a0da09 Mon Sep 17 00:00:00 2001 From: Aaron Fenyes Date: Mon, 29 Jan 2024 12:28:45 -0500 Subject: [PATCH] Correct Minkowski product; build chain of three spheres --- engine-proto/engine.jl | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/engine-proto/engine.jl b/engine-proto/engine.jl index 7e68fe4..f2dc981 100644 --- a/engine-proto/engine.jl +++ b/engine-proto/engine.jl @@ -78,7 +78,7 @@ end abstract type Relation{T} end -mprod(v, w) = v[1]*w[2] + w[1]*v[2] - dot(v[3:end], w[3:end]) +mprod(v, w) = (v[1]*w[2] + w[1]*v[2]) / 2 - dot(v[3:end], w[3:end]) # elements: point, sphere struct LiesOn{T} <: Relation{T} @@ -94,7 +94,7 @@ struct AlignsWithBy{T} <: Relation{T} elements::Vector{Element{T}} cos_angle::T - LiesOn{T}(sph1::Point{T}, sph2::Sphere{T}, cos_angle::T) where T = new{T}([sph1, sph2], cos_angle) + AlignsWithBy{T}(sph1::Sphere{T}, sph2::Sphere{T}, cos_angle::T) where T = new{T}([sph1, sph2], cos_angle) end equation(rel::AlignsWithBy) = dot(rel.elements[1].vec, rel.elements[2].vec) - rel.cos_angle @@ -166,15 +166,28 @@ end # ~~~ sandbox setup ~~~ -a = Engine.Point{Rational{Int64}}() -s = Engine.Sphere{Rational{Int64}}() -a_on_s = Engine.LiesOn{Rational{Int64}}(a, s) -ctx = Engine.Construction{Rational{Int64}}(elements = Set([a]), relations= Set([a_on_s])) +CoeffType = Rational{Int64} + +a = Engine.Point{CoeffType}() +s = Engine.Sphere{CoeffType}() +a_on_s = Engine.LiesOn{CoeffType}(a, s) +ctx = Engine.Construction{CoeffType}(elements = Set([a]), relations= Set([a_on_s])) eqns_a_s = Engine.realize(ctx) -b = Engine.Point{Rational{Int64}}() -b_on_s = Engine.LiesOn{Rational{Int64}}(b, s) +b = Engine.Point{CoeffType}() +b_on_s = Engine.LiesOn{CoeffType}(b, s) Engine.push!(ctx, b) Engine.push!(ctx, s) Engine.push!(ctx, b_on_s) -eqns_ab_s = Engine.realize(ctx) \ No newline at end of file +eqns_ab_s = Engine.realize(ctx) + +spheres = [Engine.Sphere{CoeffType}() for _ in 1:3] +tangencies = [ + Engine.AlignsWithBy{CoeffType}( + spheres[n], + spheres[mod1(n+1, length(spheres))], + -1//1 + ) + for n in 1:3 +] +ctx_chain = Engine.Construction{CoeffType}(elements = Set(spheres), relations = Set(tangencies)) \ No newline at end of file