Increasing the length of the Line

I am having two gp_Pnt (p1 and p2) and i am drawing the line between them by,

BRepBuilderAPI_MakeEdge Line = (p1,p2);

The Line was created sucessfully. Now if i want to increase the length of the Line by 10. By extending the p1 by 5 and p2 by 5. How to do that please help.

Thanks & Regards
Vidhyan

Paul Jimenez's picture

Translate each point with a vector of magnitude 5, direction p1 to p2 for p2 and reversed direction for p1, then rebuild the line.

Vidhyan's picture

Can u kindly explai with a sample code

Paul Jimenez's picture

gp_Vec v(p1, p2); // Vector from p1 to p2
v.Normalize(); // Make magnitude equal to 1
v.Multiply(5); // Scale by 5
p2.Translate(v); // Translate p2 in the direction of v
v.Reverse(); // Reverse direction of v
p1.Translate(v); // Translate p1 in the direction of v (previously reversed)
BRepBuilderAPI_MakeEdge newLine(p1, p2); // Create new line

Vidhyan's picture

Thanks a lot Paul Jimenez... It helped... Thanks