I am a Belgian engineer working on software in C# to provide smart bending solutions to a manufacturer of press brakes.
In this context I am searching for the best way to determine if two lines are parallel, based on the following information:
- Each line has two points of which the coordinates are known
- These coordinates are relative to the same frame
- So to be clear, we have four points: A (ax, ay, az), B (bx,by,bz), C (cx,cy,cz) and D (dx,dy,dz)
Which is the best way to be able to return a simple boolean that says if these two lines are parallel or not? Can someone please help me out?
Edit after reading answers Below is my C#-code, where I use two home-made objects, CS3DLine and CSVector, but the meaning of the objects speaks for itself. A toleratedPercentageDifference is used as well.
public static bool AreParallelLinesIn3D(CS3DLine left, CS3DLine right)
{
double toleratedPercentageDifference = 1;
CSVector vLeft = new CSVector(left.p1, left.p2);
CSVector vRight = new CSVector(right.p1, right.p2);
double ricoX = vLeft.X / vRight.X ;
double ricoY = vLeft.Y / vRight.Y ;
double ricoZ = vLeft.Z / vRight.Z ;
if (Math.Abs(ricoX - ricoY) > Math.Abs(toleratedPercentageDifference * ricoX / 100)) return false;
if (Math.Abs(ricoX - ricoZ) > Math.Abs(toleratedPercentageDifference * ricoX / 100)) return false;
return true;
}