# Selecting an Image

 When displaying the avatar, I place the appropriate texture map on to a polygon that is always rotated to face the local user. This angle of rotation, Towards (T), is calculated using the positions of the avatar and local user in the space. Note that here 0degrees is on the +X axis, and positive rotation is counter-clockwise. T=arctan(DZ/DX), where DZ is the difference in the two Z positions, and DX is that of the X positions. I also use T to calculate the Viewing angle (V), which is how far I would need to rotate the user's position to place him at the 270degrees position, looking down the -Z axis. V=270degrees - T

 The direction that the avatar is actually facing, the Actual angle (A), is obtained either from the network for remote avatars or supplied by the programmer for local avatars. Note that here 0degrees is on the -Z axis, and positive rotation is counter-clockwise. (This is how the CAVE library returns the tracking information, so I conformed to that strategy.)

 We can now use these values to determine the rotation of the avatar within the images, the Image angle (I). That is to say, what direction the person is looking in the movie that we recorded. Note that the direction that the person was turning within the movie is in yet another orientation of the coordinate system, so for now we will calculate it in terms of the Actual angle, and convert it later. Iactual=V + A If we look at the movie of the avatar, we see that here 0degrees is on the -X axis, and positive rotation is clockwise. A simple subtraction can be used to convert an angle expressed in terms of the Actual angle to one in expressed in relation to the Image angle. Iimages= 90 - Iactual

All of these steps can be simplified down into one quick step, with the exception of actually calculating T.

• Iimages= 90 - Iactual
• Iimages= 90 - (V + A)
• Iimages= 90 - ((270 - T) + A)
• Iimages= 90 - 270 + T - A
• Iimages= T - A -180

Now that we have the direction that the person is looking within the movie, Iimages, we can use that to select which individual image to actually use, Imagenumber. To do that we simply multiply the Iimages by the distance, in degrees, between the images.

• Imagenumber = Iimages * (360degrees / NumberOfImages)

Back to VideoAvatar