Skip to content

Autocoast #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,33 @@ version = "1.0.0-DEV"

[deps]
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
GTPSA = "b27dd330-f138-47c5-815b-40db9dd9b6e8"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
ReferenceFrameRotations = "74f56ac7-18b3-5285-802d-d4bd4f104033"
SkewLinearAlgebra = "5c889d49-8c60-4500-9d10-5d3a22e2f4b9"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
TPSAInterface = "575459ea-959c-4603-9b15-d63fb6693033"

[weakdeps]
GTPSA = "b27dd330-f138-47c5-815b-40db9dd9b6e8"

[extensions]
NonlinearNormalFormGTPSAExt = "GTPSA"

[compat]
DelimitedFiles = "1"
GTPSA = "^1"
GTPSA = "1.4"
Reexport = "1"
ReferenceFrameRotations = "3"
SkewLinearAlgebra = "1"
StaticArrays = "1"
TPSAInterface = "0.0.1"
julia = "1.9"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
GTPSA = "b27dd330-f138-47c5-815b-40db9dd9b6e8"

[targets]
test = ["Test"]
test = ["Test", "GTPSA"]
60 changes: 60 additions & 0 deletions ext/NonlinearNormalFormGTPSAExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
module NonlinearNormalFormGTPSAExt
import NonlinearNormalForm as NNF
using NonlinearNormalForm: Quaternion
using GTPSA: GTPSA, @FastGTPSA, @FastGTPSA!, TPS

function NNF.mul!(q::Quaternion{<:TPS}, q1::Quaternion{<:TPS}, q2::Quaternion{<:TPS})
@assert !(q === q1) && !(q === q2) "Aliasing q with q1 or q2 not allowed!"
@FastGTPSA! begin
q.q0 = q1.q0 * q2.q0 - q1.q1 * q2.q1 - q1.q2 * q2.q2 - q1.q3 * q2.q3
q.q1 = q1.q0 * q2.q1 + q1.q1 * q2.q0 + q1.q2 * q2.q3 - q1.q3 * q2.q2
q.q2 = q1.q0 * q2.q2 - q1.q1 * q2.q3 + q1.q2 * q2.q0 + q1.q3 * q2.q1
q.q3 = q1.q0 * q2.q3 + q1.q1 * q2.q2 - q1.q2 * q2.q1 + q1.q3 * q2.q0
end
return q
end

function NNF.:*(q1::Quaternion{<:TPS}, q2::Quaternion{<:TPS})
@FastGTPSA begin
q0 = q1.q0 * q2.q0 - q1.q1 * q2.q1 - q1.q2 * q2.q2 - q1.q3 * q2.q3
q1 = q1.q0 * q2.q1 + q1.q1 * q2.q0 + q1.q2 * q2.q3 - q1.q3 * q2.q2
q2 = q1.q0 * q2.q2 - q1.q1 * q2.q3 + q1.q2 * q2.q0 + q1.q3 * q2.q1
q3 = q1.q0 * q2.q3 + q1.q1 * q2.q2 - q1.q2 * q2.q1 + q1.q3 * q2.q0
end
return Quaternion(q0,q1,q2,q3)
end

NNF.norm(q1::Quaternion{<:TPS}) = @FastGTPSA sqrt(q1.q0^2 + q1.q1^2 + q1.q2^2 + q1.q3^2)

function NNF.inv!(q::Quaternion{<:TPS}, q1::Quaternion{<:TPS})
@assert !(q === q1) "Aliasing q with q1 not allowed!"
@FastGTPSA! begin
q.q0 = q1.q0 * q1.q0 + q1.q1 * q1.q1 + q1.q2 * q1.q2 + q1.q3 * q1.q3
q.q1 = -q1.q1/q.q0
q.q2 = -q1.q2/q.q0
q.q3 = -q1.q3/q.q0
q.q0 = q1.q0/q.q0
end
return
end

function NNF.inv(q1::Quaternion{<:TPS})
@FastGTPSA begin
q0 = q1.q0 * q1.q0 + q1.q1 * q1.q1 + q1.q2 * q1.q2 + q1.q3 * q1.q3
q1 = -q1.q1/q0
q2 = -q1.q2/q0
q3 = -q1.q3/q0
end
@FastGTPSA! q0 = q1.q0/q0
return Quaternion(q0,q1,q2,q3)
end

function NNF.show(io::IO, q::Quaternion{<:TPS})
println(io, "$(typeof(q)):")
GTPSA.show_map!(io, collect(q), Ref{Int}(1), false, [" q0:"," q1:"," q2:"," q3:"])
end

NNF.show(io::IO, ::MIME"text/plain", q::Quaternion{<:TPS}) = (println(io, "$(typeof(q)):"); GTPSA.show_map!(io, collect(q), Ref{Int}(1), false, [" q0:"," q1:"," q2:"," q3:"]))


end
Binary file removed libgtpsa.dylib
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
235 changes: 0 additions & 235 deletions src/Examples.jl

This file was deleted.

Loading
Loading