# Need help with some math

Hi all

I’ve got a table standing on a randomly undulating floor, I need this table pitch, roll and change height as each legs floor position height changes.

If I use ray casts on each leg pointed to the floor how do I turn that into pitch, roll and height.

Thanks

Hi fallenHere,

When you use a line trace you can “break the hit.” From there, you can get the Hit Normal, which will give you the “angle of the hit.” This can be used to calculate the pitch, roll, etc. You can also you the Impact Location to determine the distance (height) by simply doing this calculation:

Hit location - Leg location (tip of leg) -> Vector Length node. This will give you a Float that represents the distance between the 2 vectors.

Hope this helps!

A single vector doesn’t contain enough information to give you pitch, roll, and yaw.

You could do something like this:

Vector 1 equals A minus B, and Vector 2 equals C minus B (each of these letters are the hit positions), then you can make a rotator using a Make Rot From X Y node, with Vector 1 and Vector 2 plugged into it.

Hi

Thanks, I’ve tried normals that does not work great, each leg is on it’s own bump or dent of the floor all at different heights. The three point method sounds like a better option and I will try what you explained, one thing how do I change the height when rotating is not enough.

thanks

edit: three point method works great thanks, I think I can come up with something to change the height when the legs go through the floor, but if any suggestions please do tell!