<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-2">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff><FONT face=Arial size=2>
<DIV>To move any object in 3D Space </DIV>
<DIV>I do fallowing things:</DIV>
<DIV> </DIV>
<DIV>{</DIV>
<DIV> // l1p1 , l1p2 two poits defining line (ray) in which the object is
on start</DIV>
<DIV> // l3p1 , l3p2 two poits defining line (ray) in which the object is
on end</DIV>
<DIV> // l2p1 , l2p2 two poits defining line (direction of
movment) </DIV>
<DIV> </DIV>
<DIV> float *l1p1, *l1p2, *l2p1, *l2p2, *l3p1, *l3p2,
delta[3], v[3];<BR></DIV>
<DIV> float position1[3], position2[3], position3[3],
position4[3];<BR></DIV>
<DIV> // we define vector of movement</DIV>
<DIV> vtkGeometric::Vector(capitalaxisActorMain->GetCenter(),
capitalaxisActorMain->GetPosition(), v);</DIV>
<DIV> </DIV>
<DIV> l1p1 = RenderPanelMain->lastpickedpoint; // point in 3D
where we start picking<BR> l1p2 =
RenderPanelMain->pointbehindlastpickedpoint; // point behinde (i.e. i Z deph
+1) that point but on the line (ray)</DIV>
<DIV> </DIV>
<DIV> // we move vector in 3D space (creating a line)</DIV>
<DIV> l2p1 =
capitalaxisActorMain->GetPosition();<BR> vtkGeometric::MoveVector(v,
l2p1);<BR> l2p2 = v;</DIV>
<DIV> </DIV>
<DIV> // calculating object's position on line (l2p1, l2p2);</DIV>
<DIV> vtkGeometric::CrossLinePoints(l1p1, l1p2, l2p1, l2p2, position1,
position2);</DIV>
<DIV> </DIV>
<DIV> l3p1 = RenderPanelMain->earlierpickedpoint; // point in 3D
where we stop picking<BR> l3p2 =
RenderPanelMain->pointbehindearlierpickedpoint; // point behinde (i.e. i Z
deph +1) that point but on the line (ray)</DIV>
<DIV> </DIV>
<DIV> // calculating object's position on line (l2p1, l2p2);</DIV>
<DIV> vtkGeometric::CrossLinePoints(l3p1, l3p2, l2p1, l2p2, position3,
position4);</DIV>
<DIV> </DIV>
<DIV> // calculating shift;<BR> delta[0] = position2[0] -
position4[0];<BR> delta[1] = position2[1] - position4[1];<BR> delta[2]
= position2[2] - position4[2];<BR></DIV>
<DIV> // changing position</DIV>
<DIV> capitalplaneActorMain->AddPosition(delta);
<BR> capitalaxisActorMain->AddPosition(delta);</DIV>
<DIV>}</DIV>
<DIV> </DIV>
<DIV>void vtkGeometric::MoveVector(float v[3], float
point[3])<BR>{<BR> v[0] += point[0];<BR> v[1] +=
point[1];<BR> v[2] += point[2];<BR>}</DIV>
<DIV> </DIV>
<DIV>void vtkGeometric::Vector(float p1[3], float p2[3], float
v[3])<BR>{<BR> v[0] = p1[0]-p2[0];<BR> v[1] =
p1[1]-p2[1];<BR> v[2] = p1[2]-p2[2];<BR>}</DIV>
<DIV><BR>bool vtkGeometric::CrossLinePoints(float l1p1[3], float l1p2[3], float
l2p1[3], float l2p2[3], float pointonl1[3], float
pointonl2[3])<BR>{<BR> float v1[3], v2[3], v3[3], normal[3], t;</DIV>
<DIV> </DIV>
<DIV> Vector(l1p1, l1p2, v1);<BR> Vector(l2p1, l2p2, v2);</DIV>
<DIV> </DIV>
<DIV> vtkMath::Cross(v1, v2, v3);</DIV>
<DIV> </DIV>
<DIV> if ((v3[0] == 0.0) && (v3[1] == 0.0) && (v3[2] ==
0.0))<BR> return false; // the lines are parallel</DIV>
<DIV> </DIV>
<DIV> vtkMath::Cross(v3, v2,
normal);<BR> vtkMath::Normalize(normal);<BR> vtkPlane::IntersectWithLine(l1p1,
l1p2, normal, l2p1, t, pointonl1);</DIV>
<DIV> </DIV>
<DIV> vtkMath::Cross(v3, v1,
normal);<BR> vtkMath::Normalize(normal);<BR> vtkPlane::IntersectWithLine(l2p1,
l2p2, normal, l1p1, t, pointonl2);</DIV>
<DIV> </DIV>
<DIV> return true;<BR>}</DIV>
<DIV> </DIV>
<DIV>I hope it would help.</DIV>
<DIV> </DIV>
<DIV>micha³</FONT></DIV></BODY></HTML>