[vtkusers] vtkPlane::ProjectPoint ...(Is it orthographic based ?)

michał strzelecki nexgen at poczta.onet.pl
Tue Jul 22 18:56:02 EDT 2003

To move any object in 3D Space 
I do fallowing things:

 // l1p1 , l1p2 two poits defining line (ray) in which the object is on start
 // l3p1 , l3p2 two poits defining line (ray) in which the object is on end
 // l2p1 , l2p2 two poits defining line (direction of movment) 

 float   *l1p1, *l1p2, *l2p1, *l2p2, *l3p1, *l3p2, delta[3], v[3];

 float  position1[3], position2[3], position3[3], position4[3];

 // we define vector of movement
 vtkGeometric::Vector(capitalaxisActorMain->GetCenter(), capitalaxisActorMain->GetPosition(), v);

 l1p1 = RenderPanelMain->lastpickedpoint; // point in 3D where we start picking
 l1p2 = RenderPanelMain->pointbehindlastpickedpoint; // point behinde (i.e. i Z deph +1) that point but on the line (ray)

 // we move vector in 3D space (creating a line)
 l2p1 = capitalaxisActorMain->GetPosition();
 vtkGeometric::MoveVector(v, l2p1);
 l2p2 = v;

 // calculating object's position on line (l2p1, l2p2);
 vtkGeometric::CrossLinePoints(l1p1, l1p2, l2p1, l2p2, position1, position2);

 l3p1 = RenderPanelMain->earlierpickedpoint; // point in 3D where we stop picking
 l3p2 = RenderPanelMain->pointbehindearlierpickedpoint; // point behinde (i.e. i Z deph +1) that point but on the line (ray)

 // calculating object's position on line (l2p1, l2p2);
 vtkGeometric::CrossLinePoints(l3p1, l3p2, l2p1, l2p2, position3, position4);

 // calculating shift;
 delta[0] = position2[0] - position4[0];
 delta[1] = position2[1] - position4[1];
 delta[2] = position2[2] - position4[2];

 // changing position

void vtkGeometric::MoveVector(float v[3], float point[3])
 v[0] += point[0];
 v[1] += point[1];
 v[2] += point[2];

void vtkGeometric::Vector(float p1[3], float p2[3], float v[3])
 v[0] = p1[0]-p2[0];
 v[1] = p1[1]-p2[1];
 v[2] = p1[2]-p2[2];

bool vtkGeometric::CrossLinePoints(float l1p1[3], float l1p2[3], float l2p1[3], float l2p2[3], float pointonl1[3], float pointonl2[3])
 float v1[3], v2[3], v3[3], normal[3], t;

 Vector(l1p1, l1p2, v1);
 Vector(l2p1, l2p2, v2);

 vtkMath::Cross(v1, v2, v3);

 if ((v3[0] == 0.0) && (v3[1] == 0.0) && (v3[2] == 0.0))
  return false;  // the lines are parallel

 vtkMath::Cross(v3, v2, normal);
 vtkPlane::IntersectWithLine(l1p1, l1p2, normal, l2p1, t, pointonl1);

 vtkMath::Cross(v3, v1, normal);
 vtkPlane::IntersectWithLine(l2p1, l2p2, normal, l1p1, t, pointonl2);

 return true;

I hope it would help.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20030723/3e5d2352/attachment.htm>

More information about the vtkusers mailing list