Re: Algorithm for Vector Cross Product of N Dimensions
so just to clarify what i am doing, for reasons unknown i am making a
vector class in java and i want the vector object to be able to
perform all the operations that can be performed on a vector. the way
i am doing it now it could be possible to do this:
Vector v2d = new Vector(1, 2);
Vector v3d = new Vector(3, 4, 5);
Vector vx = v2d.cross(v3d);
i guess it should throw an exception here? i was looking for some
algorithm that could compute the cross product of vectors of arbitrary
length but it doesn't sound like i should be doing that in the first
place?
i also stumpled upon the java3d library and i think they are already
doing something like this but so far i dont like/understand the api
and it's kind of fun to do this anyway. but i notice their vector
classes inherit from tuple. is a vector a form of tuple and is the
cartesian product of a tuple the same as the cross product of a
vector? if so, can someone recommend an algorithm laid out somewhere i
can reference?
Patricia Shanahan wrote:
What exactly do you mean by "mathematically correct", and what is the data=
type of the >input? The formula would be easiest to apply, in Java, in dou=
ble, but that would involve >rounding error. If you choose one of the repre=
sentations that only involves addition, >subtraction, and multiplication yo=
u could do it exactly in BigDecimal.
so the vector coordinates could be read as int, float, or double for
what i am doing and actually the coordinates are stored as an array of
Point2D objects so that I can store the initial and terminal points in
pairs, which on second thought should be tuples which contain pairs of
"Number" instead of primitives?
public Vector(double... c) {
this.coordinates = new Point2D[c.length];
for (int i = 0; i < c.length; i++)
this.coordinates[i] = new Point2D.Double(0, c[i]);
//overloaded constructors create Point for int, Point2D.Float for
float
}//constructor
the operations from there on out are basically manipulating the values
in the array.
Patricia Shanahan wrote:
Is it possible that you meant "outer" rather than "cross"?
i did mean cross product. i dont think i ever learned outter product
but it sounds like something i should implement at some point.