cross product question
Blitz3D Forums/Blitz3D Programming/cross product question
| ||
hi.. I have a borring math problem and im a visual person.. i need to draw a line between to points in a 3D space.. out of this line i want to place a quad so it's 90 degrees on the line... the direction will at my first attemp be random... so i would also need to be able to rotate the quad around the line, but so that it still is 90 degree on the line.. i guess the trick is dross product.. and that i did make.. but look at my code.... why aren't the BLUE object not always 90 on the two RED and GREEN line.. ???... (press a and the will shift RND) what are my doing wrong and how to fix it.. :) help any one. :) Graphics3D 640,480, 0, 2 SetBuffer BackBuffer() cam = CreateCamera() PositionEntity cam, 50,50,50 CameraClsColor cam, 255,255,255 o1 = CreateCube() ScaleEntity o1, 1,1,10 EntityColor o1, 255,0,0 o2 = CreateCube() ScaleEntity o2, 1,1,10 EntityColor o2, 0,255,0 o3 = CreateCube() ScaleEntity o3, 1,1,10 EntityColor o3, 0,0,255 v1x# = 10 v1y# = 5 v1z# = 28 v2x# = 1 v2y# = 5 v2z# = 40 v3x# = 0 v3y# = 0 v3z# = 0 Repeat MoveEntity cam, 2,0,0 PointEntity cam, o1 CameraClsMode cam, True, True AlignToVector o1, v1x, v1y, v1z, y AlignToVector o2, v2x, v2x, v2z, y If KeyHit(30) Then v2x# = Rnd(-10,10) v2y# = Rnd(-10,10) v2z# = Rnd(-10,10) End If ;Cross product cx# = ( v1y * v2z ) - ( v1z * v2y ) cy# = ( v1z * v2x ) - ( v1x * v2z ) cz# = ( v1x * v2y ) - ( v1y * v2x ) AlignToVector o3, cx,cy,cz, y RenderWorld Flip() Until KeyHit(1) End ; ;code snippet from Jeppe Nielsen.. thx ; ; ;Cross product ; cx# = ( dy1 * dz2 ) - ( dz1 * dy2 ) ; cy# = ( dz1 * dx2 ) - ( dx1 * dz2 ) ; cz# = ( dx1 * dy2 ) - ( dy1 * dx2 ) ; ; AlignToVector c\pivot,cx,cy,cz,1 |
| ||
You have AlignToVector o1,v2x,v2x,v2z, y EDIT: i meant to put o2 where the o1 is. Where is the v2y? This probably has nothing to do with what you asked. |