Sign in to follow this  
spawn_thang

Cross product problem

Recommended Posts

I have encountered a problem with a cross product calculation that I would like some help with if possible.
The problem is that I can create a vector that is perpendicular, ninety degrees to one of the axis but I want the vector to be perpendicular to both axis. The code for the cross product is like this and this creates the object in the images. The original quad is originally set to be very un orthographic (very un centered ) on all axis as a test.

I then brought the object into another application to get a better view of the object.

Your help would be very much appreciated with this.

The code :


pv1->x = vtx[p].pos.x;
pv1->y = vtx[p].pos.y;
pv1->z = vtx[p].pos.z;
pv2->x = vtx[p1].norm.x;
pv2->y = vtx[p1].norm.y;
pv2->z = vtx[p1].norm.z;

D3DXVec3Cross( v_res,
pv1,
pv2 );

vtx[4].pos.x = v_res->x;
vtx[4].pos.y = v_res->y;
vtx[4].pos.z = v_res->z ;

Returns a result of :

[img]http://i307.photobucket.com/albums/nn292/frog_mate/p1.jpg[/img]


[img]http://i307.photobucket.com/albums/nn292/frog_mate/p2.jpg[/img]

[img]http://i307.photobucket.com/albums/nn292/frog_mate/p3.jpg[/img] Edited by Thermal Blast

Share this post


Link to post
Share on other sites
It is somewhat unclear of what really is your issue. The cross product will calcualte the perpendicular vector of two given vectors, right ? Are you trying to calcualte the perpendicular [i]edge [/i]of two other [i]edges. [/i]The difference is, that an edge is a located 'vector', that is you have not only the direction given by a vector but although the position . If you have two edges with a shared vertex, then try something like this:

[CODE]
edge_1 = (v0,v1)
edge_2 = (v0,v2)
new_direction = crossProd( v1-v0, v2-v0)
new_edge = (v0, v0+new_direction)
[/CODE] Edited by Ashaman73

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this