# How to align a 3D object with four points?

I'm sure there's a better way to articulate this question, but I lack the vocabulary.

Imagine a skateboard. As it rolls straight down a road, the "deck" is aligned with the road, just offset a few inches higher.

If the skateboard is on a ramp with an incline of say 20º, then then deck of the skateboard can be aligned with the ramp by rotating along it's x-axis by 20º.

But what if the skateboard approaches the ramp at an angle?

Perhaps a visual explanation might be easier to understand.

If I know the points at the top of each pink/purple pole, and I wanted to place an object in the scene that aligned with those points, like this...

Is there some known method for figuring this out?

I'm using Unity, if that makes a difference?

• Correct. As Philipp pointed out in their answer, there's two possible solutions to that question. Which I now understand is solvable by discarding the lowest of the four points. – gargantuan Jan 22 '20 at 17:30

You can now use the surface normal of this triangle as the surface normal of the board. A good explanation how to do this can be found in this stackoverflow answer. The resulting vector is a direction which you can convert into a quaternion using SetLookRotation and assign to transform.rotation.
The transform.position is the average of the two highest points.