Start drafting engine prototype

This commit is contained in:
Aaron Fenyes 2024-01-24 11:16:24 -05:00
parent c48d685ad6
commit b864cf7866

34
engine-proto/engine.jl Normal file
View File

@ -0,0 +1,34 @@
module Engine
export Construction, Sphere, mprod, point
using LinearAlgebra
using Groebner
mutable struct Construction
nextid::Int64
Construction(; nextid = 0) = new(nextid)
end
struct Sphere{T<:Number}
vec::Vector{T}
id
function Sphere(vec::Vector{T}, ctx::Construction) where T <: Number
id = ctx.nextid
ctx.nextid += 1
new{T}(vec, id)
end
end
function mprod(sv::Sphere, sw::Sphere)
v = sv.vec
w = sw.vec
v[1]*w[2] + v[2]*w[1] - dot(v[3:end], w[3:end])
end
point(pt::Vector{<:Number}, ctx::Construction) =
Sphere([one(eltype(pt)), dot(pt, pt), pt...], ctx)
end