Calculate camera angle for tile width/height

import math
def GetIsoCamPitch(w=256,h=128):
 r = float(float(h)/float(w))
 return math.degrees(math.asin(r))
def GetTileSizeFromCameraPitch(a=45,w=0,h=0,ret='r'):
 Get the ratio, w, or h, from camera's pitch a
 If w is provided then h is ignored, vice-versa
 r = math.sin(math.radians(a))
 if 'r' in ret:
 return r
 if 'w' in ret:
 # this assumes that h was provided for
 return 1/r*h
 if 'h' in ret:
 #assumes that w was provided
 return w*r

print GetTileRatioFromCameraPitch(35,w=256,ret='h')

Code (Python) to calculate the camera down (pitch) angle to achieve a Tile width/height ratio, and get tile ratio from camera pitch.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s