x#, y#, z# = components of a vector in 3d space source_entity = handle of source entity, or 0 for 3d world dest_entity = handle of destination entity, or 0 for 3d world |
Transforms between coordinate systems. After using dxTFormVector the new components can be read with dxTFormedX(), dxTFormedY() and dxTFormedZ(). See dxEntityX() for details about local coordinates. Similar to dxTFormPoint, but operates on a vector. A vector can be thought of as 'displacement relative to current location'. For example, vector (1,2,3) means one step to the right, two steps up and three steps forward. This is analogous to dxPositionEntity and dxMoveEntity: dxPositionEntity entity, x,y,z ; put entity at point (x,y,z) dxMoveEntity entity, x,y,z ; add vector (x,y,z) to current position |
; dxTFormVector example dxGraphics3D 640, 480 p = dxCreatePivot() dxPositionEntity p, 10, 20, 30 ; easy to visualize dxTurnEntity p, -5, -15, 25 ; hard to visualize ; Question: what would happen if we took one step 'forward'? ; The local vector corresponding to one step forward is (0,0,1) ; in the pivot's local space. We need the global version. dxTFormVector 0,0,1, p,0 ; transform from pivot to world message$ = "'One step forward' vector is ( " message = message + dxTFormedX() + ", " + dxTFormedY() + ", " + dxTFormedZ() + " )" dxText 70, 180, message ; Now actually take the step. The new location should be ; (10,20,30) plus the vector we just computed. dxMoveEntity p, 0,0,1 message$ = "New location of pivot is ( " message = message + dxEntityX(p) + ", " message = message + dxEntityY(p) + ", " + dxEntityZ(p) + " )" dxText 100, 210, message dxFlip dxWaitKey() End |