# Cross product problem

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

## 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

.pos.x;
pv1->y = vtx

.pos.y;
pv1->z = vtx

.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 :

Edited by Thermal Blast

##### 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 edge of two other edges. 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:

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

##### Share on other sites
Thank you, that looks like the very thing I have been looking for.

• 30
• 15
• 23
• 10
• 19