Engine prototype #13
34
engine-proto/engine.jl
Normal file
34
engine-proto/engine.jl
Normal 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
|
Loading…
Reference in New Issue
Block a user