How far does something have to be till it becomes a point?

Started by
12 comments, last by LilBudyWizer 18 years, 5 months ago
Hi, I have another related problem.

I made a small app so I can visualise matrices, I have a triangle with all sides being 20 units.

I wanted to calculate how far back the triangle would have to be from the camera in order for it to just fit in the window and got some strange results.

I used the formula:

           triangle height * distance to projection planedistance = ------------------------------------------------                         desired height            


the width and height of my viewport is 640x480

so I went with

distance = 20*distance to projection plane           -------------------------------                       480


but that ended up making the triangle much smaller than the viewport

so I instead of using the height of the view I decided to use the width

distance = 20*distance to projection plane           -------------------------------                       640


which worked

here is an image

I am a bit confused to why I had to use the width as I am trying to fit the triangle based on its height, I must be quite not understanding something, can someone help me and explain what I am missing?

regards

Fluxtah
A wise man can learn more from a foolish question, than a fool can learn from a wise answer - Bruce Lee
Advertisement
I think that the formula you are using assumes that the triangle is oriented point up. In that case the height should be 18.2 instead of 20. However, because the triangle is on its side, a height of 20 would seem appropriate, but it throws off the fit. Because you then use the width, it kind of cancels out. It's a square fit, so it works out in the end. Try using the proper triangle height (sqrt(300)) and the window height, and see if it does what you expected.
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)
Thanks for the reply, I realise now that I was calculating the distance to the projection plane wrong, in DirectX it seems they use the vertical FOV rather than the horizontal.

cheers

Fluxtah
A wise man can learn more from a foolish question, than a fool can learn from a wise answer - Bruce Lee
OpenGL does as well.
Keys to success: Ability, ambition and opportunity.

This topic is closed to new replies.

Advertisement