A few answers:
1. Use struct subtyping to give a type that includes both kinds:
(struct dual ())
(struct quaternion dual (scalar vector))
(struct dual-quaternon dual (real dual))
2. Use a library that supports algebraic data types, such as
On Sun, Feb 4, 2018 at 9:16 AM, HiPhish <hiph...@openmailbox.org> wrote:
> Hell Racketeers,
> I am trying to write an implementation of the mathematical concept of dual
> quaternions in Racket. Dual quaternions are an algebraic type and there are
> several equally valid way to look at them.
> Let me give some background first. A dual number (a + bε) is similar to a
> complex number (a + bi), except that the square of ε is 0 instead of -1. A
> quaternion (a + bi + cj + dk) is like a complex number, except that it has
> three complex units which all square to -1. A dual quaternion is either a
> number where both components are quaternions, or a quaternion where all four
> components are dual numbers. There are also "subtypes" of dual quaternoins:
> dual scalar is a dual quaternions where the vector parts of the two
> are zero, and a dual vector (not to be confused with the dual vectors from
> linear algebra) is a dual quaternions where the scalar part of both
> is zero. Unlike the subtypes in OOP these algebraic subtypes have *less*
> information than their parent (kind of like a square is a rectangle defined
> only one length instead of two). (If you want to get really down to it, dual
> quaternions are elements of the Clifford algebra Cl^+(0, 3, 1).)
> So my question is: what would be the best way of defining such algebraic
> At first I wanted to create a struct:
> (define vector (i j k))
> (struct quaternion (scalar vector))
> (struct dual-quaternon (real dual))
> But this limits me to a "dual number where both components are quaternions"
> view of the type. It also means that each dual scalar has be a sort of
> mishapped dual quaternion.
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
For more options, visit https://groups.google.com/d/optout.