spire icon indicating copy to clipboard operation
spire copied to clipboard

Have a type class with vector cross product for 3 dimensional space

Open pleira opened this issue 10 years ago • 2 comments

Spire could have a type class implementing the vector cross product, which I would call something like EuclideanVectorSpace or EuclideanCoordinateSpace. This is an operation that is only suitable for 3 dimensional vector spaces and it is often used in physics.

I have done a preliminary implementation, offering a method angle as well. As the current CoordinateSpace might be replaced, it would be interesting to bring the cross product operation along with the replacement, or in a subproject from Spire.

pleira avatar Feb 10 '15 10:02 pleira

I had a look at the cross-product implementation. It requires the addition of a typeclass + syntax just for the cross-product operation (but warning: Euclidean spaces can have dimensions other than 3).

I'm thinking it should be a method on the Vec trait, requiring evidence that the dimension is indeed 3 (see #628 for fixed-size Vecs).

Another possibility: find a suitable generalization of the cross-product (exterior algebras?), and add a generic typeclass for that.

denisrosset avatar Feb 25 '17 08:02 denisrosset

Amazing the idea of using exterior algebras for this. I did not know anything about that. It would be cool if the normal 3 dimensional cross-product would be a kind of corollary of a more generic algebra. Having said that, I am quite fine with a method implementation as #628 tries to do for fixed-size Vecs.

pleira avatar Feb 26 '17 23:02 pleira