Engine prototype #13

Merged
glen merged 133 commits from engine-proto into main 2024-10-21 03:18:48 +00:00
Showing only changes of commit b864cf7866 - Show all commits

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