Plane perpendicular to line(a,b)

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Plane perpendicular to line(a,b)

Post by keithsloan52 »

Okay I have two points a and b, vector(a) and vector(b). I wish to construct a plane perpendicular to the line(a,b) passing through a)
I know if I have two vectors I can create a perpendicular plane with the cross product and that in 2d I can create
a vector at 90 degrees by swapping x and y values and making one negative, but what about 3D?

projectToPlane(Vector1,Vector2)
Description: projects the vector on a plane defined by a point (Vector1) and a normal (Vector2).
Returns: nothing

Looked promising but returns nothing, so lost as to what it does.
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Plane perpendicular to line(a,b)

Post by openBrain »

Considering A & B are of App.Vector type.
Create a standard plane 'myPlane' (located at 0,0,0 and normal to Z axis) then

Code: Select all

myPlane.Placement = App.Placement(A, App.Rotation(App.Vector(0,0,1), B-A))
Post Reply