Jump to content
  • Advertisement
Sign in to follow this  
errantkid

Can I replace the cross product with the wedge product?

This topic is 3409 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

As you know the cross product is only defined for vectors in 3 and 7 dimensions. Now I would like to implement an analog to the cross product in 2 dimensions which produces a scalar as follows: (x0, y0) ^ (x1, y1) = x0.y1 - y0.x1 (where . is multiplication) So I was thinking that since my place of work has opted to use ^ as a cross product, it seems quite elegant to instead redefine the ^ operator as the (Hodge dual of the) wedge product since this happens to be equivalent to the cross product in three dimensions. In other words: *(A^B) = A x B in three dimensions. (where * is the Hodge Dual operator, ^ is the wedge product and x is the cross product) As far as I can tell this also does what I want it to in two dimensions (using this reference): *(A^B) = A0.B1 - A1.B0 in two dimensions QUESTION: 1. So I had been thinking, is it permissible to replace our ^ operator with the Hodge Dual of a wedge product for vectors of all dimensions? 2. In other words could I extend this operation in a useful manner to vectors of higher dimensions? 3. And finally I suppose you could then write all *(A^B) in a matrix form? E.g. as for the 3D cross-product:
        [  0  -A2   A1 ]   [ B0 ]
A x B = [  A2  0   -A0 ] * [ B1 ]
        [ -A1  A0   0  ]   [ B2 ]
Unfortunately I have some pressing deadlines so I can't spend too much time studying the math. Any commentary will be much appreciated and I apologize for any ignorance on my part! ;)

Share this post


Link to post
Share on other sites
Advertisement
The dual of a 2-blade in 3 dimenions results in a 1-blade (vector) perpendicular to this 2-blade (where the 2-blade represents a plane in euclidian space).

n = (a ^ b)*

This can easily be used in the same way for higher dimensions, but will not have the geometrical significance of a normal vector. Instead, the dual of a plane in 4D will result in another (dual)plane.

In short, only the dual of a pseudoscalar results in a scalar. A pseudoscalar is a k-blade in a k-dimensional space (plane in 2D, sphere in 3D, hypersphere in 4D).

The crossproduct only works for 3D (and for converted 2D).

About the matrices, I'm not sure it's that easy. I've never looked into it.

Share this post


Link to post
Share on other sites
I'm afraid most of that went over my head (I'm sorry I have no experience with Clifford algebra), but I think I get what you're saying anyway, since I suspected as much. From here the 4d dual of a bi-vector is this:
Dual(e31) = e1234 . e31 = e42
which is still a bi-vector. (I hope I'm making sense since I don't really know what I'm talking about ;) )

I guess I was trying to find a nice analog to the cross-product which is general enough to be meaningful for all dimensions but happens to give the determinant in two dimensions and the cross product in three dimensions... It seems inelegant to limit an operator to a finite number of dimensions. (Damn you Nature! :) )

Share this post


Link to post
Share on other sites
The cross product is defined for n-dimensional space and you need n-1 vectors to calculate it. For 3D it's:

[ i j k ]
u (x) v = [ ux uy uz ]
[ vx vy vz ]


I'm not sure it makes sense for 2D (I used the concept sometimes):

(x)(u) = [ i j ] = [ uy, -ux ]
[ ux uy ]

For 4D it's:

[ i j k l ]
(x)(u, v, w) = [ ux uy uz uw ]
[ vx vy vz vw ]
[ wx wy wz ww ]

And so on...

Share this post


Link to post
Share on other sites
Hi rozz, ah yes thanks I take your meaning! To give some context, I was previously looking at this thread.

I'm actually looking for an alternative operator to the cross-product that happens to suit my needs (I.e. an operator that operates on only two operands). The wedge product happens to do what I want for the 2D and the 3D case and looks a lot like the binary ^ operator. On the other hand combining three operands using ^ is not possible, so essentially I want to redefine my old cross-product ^ as a wedge-product ^.

I'm thinking if you want to retain the cross product, maybe you should define it as cross(x,y,z,...) to retain consistency across all dimensions.

So I guess I'm testing the water to see whether others think that it would be a good idea to redefine my ^ as a dual(wedge product). Unfortunately this dual wedge product doesn't seem to extend nicely past 3 dimensions :_(

Share this post


Link to post
Share on other sites
The cross product has a geometric meaning that is useful in 3 dimensions..what good is it for 2 or n-dimensions, whats the point?

Share this post


Link to post
Share on other sites
Well, the cross product is definitely useful in 2 dimensions: it gives you an orthogonal vector.
The wedge product is also useful in 2 dimensions: it gives you the determinant of | A B | which is what I'm using right now for triangle-triangle intersection.

As for higher dimensions, who knows what it's useful for? For example, I used to think that eigen-vectors and eigen-values were useless too, but since then I've discovered a multitude of uses for them. Admittedly I can't imagine a use for the 4d wedge product, but maybe someone will disagree with me?

Share this post


Link to post
Share on other sites
Quote:
Original post by errantkid
2. In other words could I extend this operation in a useful manner to vectors of higher dimensions?
You might, but even so I would consider it bad for a number of reasons, including being overengineered and overly complex. (In fact, I consider overloading circumflex to be the cross product to be bad form, but that's a different discussion.)

You are better off defining a normal cross product for your 3-vectors and a pseudo-cross product for your 2-vectors. People who will use your code in the future will thank you.

Share this post


Link to post
Share on other sites
Found this quote by Dmytry which sums it up nicely:

Quote:

In 3D only. In other dimensions, cross product is not well defined, but there is well-defined analogs.

In any other number of dimensions >=2, there's at least 2 different cross-product "analogs", depending to what properties of 3D cross product we want it to mimic. And 3D is just only special case when both things is the same... and there's many other useful functions possible, that is somewhat like cross product...

In 2D,
CrossProductAnalog1(U,V)=(U.x*V.y-U.y*V.x)
CrossProductAnalog2(U)=(U.y, -U.x)
(yes, second analog takes only one argument, and return orthogonal vector :)
First analog makes some physical and geometrical sense, second analog comes from "determinant rule", for determinant of 2x2 matrix,
|A B|
|C D| = AD-BC


And in 4D, there is one analog that takes 2 4D vectors at input and return 6D vector as result. And other analog that takes 3 4D vectors, and have 4D vector as result. (3 vectors is necessary to define volume, and returned result is "normal of that volume" )

Also, in 3D we can define another nice operation that takes 3 vectors at inputs, and return scalar, and is eqivalent to first 2D cross product analog.

SomeFunction(A,B,C)=(A x B . C)
- return volume of paralelepiped(sp?)
(note that order of operands does not matter...)

in summary,
1: 2D cross product is not defined by itself. In general, there's several analogs, and no analogs is completely equivalent.

2: you can define whatever function you *really* need and can use, and then use it.
3:It is not useful to make cross product routine if you don't know it's properties.

Also, "analog" doesn't really have any mathematical sense, just some properties is somewhat similar.

Share this post


Link to post
Share on other sites
Quote:
You might, but even so I would consider it bad for a number of reasons, including being overengineered and overly complex. (In fact, I consider overloading circumflex to be the cross product to be bad form, but that's a different discussion.)

Thanks, I suspected that people might feel this way. It seems I'm not the first person who has thought to do this either: thread

My problem is mainly that I want to write this kind of thing more elegantly:
det1 = p1[0]*q[1]-q[0]*p1[1];
gama1 = (p1[0]*r[1]-r[0]*p1[1])*det1;
alpha1 = (r[0]*q[1] - q[0]*r[1])*det1;
alpha1_legal = (alpha1>=0) && (alpha1<=(det1*det1) && (det1!=0));
det2 = p2[0]*q[1] - q[0]*p2[1];
alpha2 = (r[0]*q[1] - q[0]*r[1]) *det2;
gama2 = (p2[0]*r[1] - r[0]*p2[1]) * det2;


Which is from Oren Tropp's triangle intersection algo but I guess I'm stuck with it :) Perhaps I should just define a determinant function so that
det1 = det(p1,q);
gama1 = det(p1,r)*det1;
alpha1 = det(r,q)*det1;
alpha1_legal = (alpha1>=0) && (alpha1<=(det1*det1) && (det1!=0));
det2 = det(p2,q);
alpha2 = det(r,q) * det2;
gama2 = det(p2,r) * det2;


Quote:
People who will use your code in the future will thank you

No they won't, but at least they won't complain either :). I'm a fan of your blog by the way, kudos for that

Quote:
Found this quote by Dmytry which sums it up nicely

Thanks :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!