Working in Swift, ARTKit / SceneKit
I have a line AB in 3d and I have xyz coordinates of both points A and B. I also have a point C and I know its xyz coordinates too.
Now, I want to find out the xyz coordinates of point D on line AB; given that CD is perpendicular to AB.
What would be a simple way to do it in Swift.
Parameterize the line
AB
with a scalart
:The point
D = P(t)
is such thatCD
is perpendicular toAB
, i.e. their dot product is zero:Swift code: