Programming4us
         
 
 
Windows Phone

Developing for Windows Phone and Xbox Live : 3D Math Basics (part 1) - Coordinate Systems

12/14/2010 4:57:53 PM
Those who are new to 3D graphics might ask the question, “Do I need to know math to create 3D graphics?” The simple answer is “Yes, there is a level of mathematics that is required when you are working on a 3D game.” Can you get by without knowing much? Absolutely, and we have seen many examples where people have created a 3D game but don’t necessarily understand how they are getting the results they see. This often leads to questions such as, “Why is my model orbiting around the camera when I wanted it to rotate on its axis like a planet?”

Without a doubt, having a better understanding of underlying mathematics leads you to be less confused, more quickly understand new concepts, and be more productive.

This section attempts to strike a balance of theory and practical use. The goal is to give you the higher level concepts that are used throughout 3D graphics without having to explain the details of how to do specific mathematical operations such as vector arithmetic or matrix multiplication. There are countless educational sources on these operations, and they are already implemented in the math types provided in XNA Game Studio. We spend our time focusing on what these operations mean geometrically and how they are used within 3D graphics.

Coordinate Systems

We already used one type of coordinate system, which were screen coordinates when drawing sprites on the screen. In screen coordinate space, there are two dimensions: one for each of the X and Y directions. In screen coordinates, the X direction increases in value from the left side of the screen to the right, and the Y increases in value from the top of the screen to the bottom.

There are two main types of 3D coordinate systems used in computer graphics. These two different types differ in direction from the positive Z points relative to the X and Y axes. The two types of coordinate systems are called right-handed and left-handed (see Figure 1). Both of these systems contain three directions for the X, Y, and Z axes. The three axes converge at a central point called the origin where their values equal 0. The values along each axis either gain or lower in value at regular intervals depending on whether you are moving in the positive or negative direction along that axis.

Figure 1. Left- and right-handed coordinate systems


To visualize these two different coordinate systems, let’s do a quick exercise. Take your right hand and make a fist. Turn your hand so your bent fingers face you and the top of your hand faces away from you. Now, extend your thumb. It should point directly to your right. Your thumb represents the positive X axis. Now extend your index finger, also known as your pointer finger, directly up in the air. This represents the positive Y direction. Your hand should look like it is making a capital L now with your thumb facing right and representing the positive X axis and your index finger pointing upwards representing the positive Y axis. Finally, extend your middle finger and point it directly at yourself. Your middle finger represents the positive Z axis (see Figure 2).

Figure 2. Right fist forming the right-handed coordinate system


Imagine lines that extend from the tips of all three of your fingers; they should be 90 degrees apart from each other forming right angles between themselves. Having each axis be at right angles from each other creates what is called an orthogonal coordinate system. In this case, you created a right-handed coordinate system. This is the coordinate system used by default in XNA Game Studio. In a right-handed coordinate system, the negative Z axis is used for the forward direction.

Note

DirectX by default uses a left-handed coordinate system. The properties and methods in XNA Game Studio assume you are using a right-handed coordinate system. Some methods also provide a left-handed equivalent for those who want to use a left-handed system.


To visualize a left-handed system, follow the previous instruction except face your palm away from yourself but still make a capital L with your thumb and index finger for the positive X and Y axes. Now when you extend your middle finger to form the positive Z axis, notice that it now points away from you. In a left-handed coordinate system, the positive Z axis is used for the forward direction (see Figure 3).

Figure 3. Left fist forming the left-handed coordinate system


Note

Although we just stated that Z axis is used for the forward direction, this is not always true. In some 3D art creation packages, the Z axis actually represents the up direction. The good news is that this difference is accounted for when XNA Game Studio loads models from those specific 3D content packages.

Other -----------------
- Developing for Windows Phone and Xbox Live : Introduction to 3D Graphics
- Windows Phone 7 : Setting Your Website Preference
- Windows Phone 7 : Browsing the Web - Changing Privacy Settings
- Windows Phone 7 : Finding Text on a Web Page
- Windows Phone 7 : Working with Browsing History
- Windows Phone 7 : Browsing the Web - Sharing Links
- Windows Phone 7 : Pinning a Website to Start
- Windows Phone 7 : Saving a Favorite Site
- Windows Phone 7 : Browsing the Web - Understanding the Mobile Web
- Windows Phone 7 : Browsing the Web - Using Instant Answers
- Windows Phone 7 : Browsing the Web - Searching the Web
- Windows Phone 7 : Browsing the Web - Browsing with Tabs
- Windows Phone 7 : Browsing the Web - Opening a Web Page
- Windows Phone 7 : Browsing the Web - Browsing Basics
- Windows Phone 7 : Working with the Calendar - Juggling Multiple Calendars
- Windows Phone 7 : Working with the Calendar - Responding to an Invitation
- Windows Phone 7 : Working with the Calendar - Sending an Invitation
- Windows Phone 7 : Working with the Calendar - Changing Calendar Views
- Windows Phone 7 : Working with the Calendar - Deleting Appointments
- Windows Phone 7 : Working with the Calendar - Editing Appointments
 
 
Most View
- Windows Home Server 2011 : Configuring the Microsoft Management Console (part 2) - Creating a Custom Taskpad View, Controlling Snap-Ins with Group Policies
- Programming Windows Phone 7 : Color Themes
- Windows 7 : Setting Up the Remote Computer as a Host (part 1) - Configuring Windows 7 or Vista to Act as a Remote Desktop Host
- SQL Server Integration Services : A Data Transformation Requirement
- Other SQL Server XML Support
- Exchange Server 2010 Mailbox Services Configuration (part 3)
- Exchange Server 2010 : Edge Transport and Messaging Security (part 1)
- SharePoint 2010 : Choose a Column Type (part 9)
- CSS for Mobile Browsers : Common Patterns (part 1) - Absolute and floating positions
- PerformancePoint Services 2010 (part 1) - Understanding the Architecture of PerformancePoint Services 2010
Top 10
- Implementing Edge Services for an Exchange Server 2007 Environment : Utilizing the Basic Sender and Recipient Connection Filters (part 3) - Configuring Recipient Filtering
- Implementing Edge Services for an Exchange Server 2007 Environment : Utilizing the Basic Sender and Recipient Connection Filters (part 2)
- Implementing Edge Services for an Exchange Server 2007 Environment : Utilizing the Basic Sender and Recipient Connection Filters (part 1)
- Implementing Edge Services for an Exchange Server 2007 Environment : Installing and Configuring the Edge Transport Server Components
- What's New in SharePoint 2013 (part 7) - BCS
- What's New in SharePoint 2013 (part 6) - SEARCH
- What's New in SharePoint 2013 (part 6) - WEB CONTENT MANAGEMENT
- What's New in SharePoint 2013 (part 5) - ENTERPRISE CONTENT MANAGEMENT
- What's New in SharePoint 2013 (part 4) - WORKFLOWS
- What's New in SharePoint 2013 (part 3) - REMOTE EVENTS