# 3d math • ### Question

• If the height of a square was represented as c, and the distance between the viewer and the square was b, then what would the height of the square, a, as it appears to the viewer? How can I use the Pythagorean Theorem here?
~~AirWaves!!~~
Thursday, December 15, 2011 6:41 AM

• You could calculate it with simple mathematics. Just draw it on a paper:

You have a ground level. Somewhere is you object with height a. And your camera is on some other position - also on a specific height. Now you could draw a line parallel to the ground that goes through your camera.

Now you can draw lines from your camera to the points of your object and you get 2 triangles which both have a 90 degree corner so you can use the Pythagorean Theorem.

But that was 2D only ... but in 3D it is the same. The line for the ground is just not an line but an area. And the triangle goes to a corner.

But this theorie with the Pythagorean Theorem is not uses as far as I know. Instead in 3d you use matrices. So I would suggest searching on mathematics with matrices in combination with 3D.

With kind regards,

• Marked as answer by Saturday, December 17, 2011 5:14 AM
Thursday, December 15, 2011 7:47 AM
• In this case, the apparent height a, depends linearly on the actual height c and the distance from the viewer b:

a = c / b

It only gets more complicated with matrices when the viewer rotates or the shapes move in complicated ways in 3D like rotating - if the viewer is stationary and the shapes don't have actual 3D geometry (they are just scaled with distance)the above will work.

Example here, import GVC080

• Edited by Thursday, December 15, 2011 3:56 PM
• Marked as answer by Saturday, December 17, 2011 5:14 AM
Thursday, December 15, 2011 10:55 AM

### All replies

• You could calculate it with simple mathematics. Just draw it on a paper:

You have a ground level. Somewhere is you object with height a. And your camera is on some other position - also on a specific height. Now you could draw a line parallel to the ground that goes through your camera.

Now you can draw lines from your camera to the points of your object and you get 2 triangles which both have a 90 degree corner so you can use the Pythagorean Theorem.

But that was 2D only ... but in 3D it is the same. The line for the ground is just not an line but an area. And the triangle goes to a corner.

But this theorie with the Pythagorean Theorem is not uses as far as I know. Instead in 3d you use matrices. So I would suggest searching on mathematics with matrices in combination with 3D.

With kind regards,

• Marked as answer by Saturday, December 17, 2011 5:14 AM
Thursday, December 15, 2011 7:47 AM
• In this case, the apparent height a, depends linearly on the actual height c and the distance from the viewer b:

a = c / b

It only gets more complicated with matrices when the viewer rotates or the shapes move in complicated ways in 3D like rotating - if the viewer is stationary and the shapes don't have actual 3D geometry (they are just scaled with distance)the above will work.

Example here, import GVC080

• Edited by Thursday, December 15, 2011 3:56 PM
• Marked as answer by Saturday, December 17, 2011 5:14 AM
Thursday, December 15, 2011 10:55 AM
• ~~AirWaves!!~~
Saturday, December 17, 2011 5:15 AM
• So litdev, how would I get the angle to rotate the cube, from a certain angle. Also, how would I get the width of one side of the cube, say if I was moving around the cube so that one side's width was lessening?
~~AirWaves!!~~
Saturday, December 17, 2011 5:18 AM
• Nevermind, I figured out my own solution:

Width = ((rectSize / dist) - ((rectSize / dist) / (180 / angle))) * 2000

~~AirWaves!!~~
Saturday, December 17, 2011 8:03 AM