Rotation calculation problem

Nickk888

New member
Joined
Jan 17, 2015
Messages
2
Hello dear FreeMathHelp forum, at first, sorry for my english if i make a mistake at it, i'm German.
And please move the topic in the right category if it is in the wrong category.

So, i made a game server and i'm a scripter in it. So, to go with the topic, i have a Tree, i try to make it fall with the ground height, the stand rotation are 0.0(zero) deg., and 90.0 deg. are laying straight, the problem is that the tree are laying in the air or in the ground because of the terrain height, so i calculate the height of the tree and the height of the ground where it should fall and laying, so for explain:

Tree Z height: 23.0 deg.
Z height terrain: 28.0 deg.

So if i try to make it straight fall to 90.0 deg. the Tree are under the terrain because the terrain are 28 deg. and the tree are 23 deg.
I try by myself to make an calculation but it is wrong:

if(layZ > z) layRot = -(layZ - z) - 90;
if(layZ < z) layRot = (z - layZ) + 90;

So it works like this, if the Lay height are over the normal height then the layRot are equal -(28.0 - 23.0), so it is then -5.
"z" is the tree height and "layZ" are the height of the terrain where it should fall, "layRot" is zero(0) and there should be the rotation of the tree calculates of the heights.

So it calculate how height it is between the height A and height B, but its not the rotation but height Coordinate, so how can i calculate to become the lay rotation that the Tree are not floating in the air and its not in the ground?

I hope you guys can me help, i'm not very good at Math.
Regards.
 
Thanks for the Answer, i want to calculate the Rotation that the tree i will rotate is'nt In the ground and above the ground, i have made a little picture what i ment:
6z7BJwV.jpg
So, the ground where the tree are is Z: 23, thants the height in the 3D World, and i want to fall the tree ON the ground 3 meters to the right and thats the height of Z: 28 because of the terrain height, so if i rotate the tree 90 deg. then the tree are IN the ground and not ON it, so do you know how to calculate the rotation thats it on the ground? So it should be maybe 75 deg. Rotation and not 90 deg.

How can i calculate the rotation with the heights?
xJRwWZ8.jpg
 
Top