First, let's familiarize ourselves with how the WCS looks. I've drawn a pyramid in AutoCAD and shown it from several different angles:

The WCS is displayed in all four pictures (and, naturally, is exactly the same in each picture). One of the techniques for dealing with 3D when you are "doing the math" (perhaps in your own code) and want to make sure the math (or code) you're writing matches the geometry you're working with is known as "the right hand rule." (We're going to use this for some math coming up in a few paragraphs.) For each picture, look at the WCS and orient your

**right**hand (which should be open face initially) so that your fingers are pointing in the direction of the x-axis and your palm is open toward the direction of the y-axis. (Don't think about your arm, just your hand. The arm will just go wherever it needs to go, though it may look funny to onlookers.) Curl your fingers into your palm and stick your thumb out. If you've done it correctly, your thumb should be pointing in the direction of the z-axis. If you can do this with all four pictures, you're well on your way to being able to understand the rest of the math in this post.

In math notation, we might write the relationship above as something like

**z**=

**x**×

**y**. The relationships which apply to the WCS (and all UCSs) are

**x**=**y**×**z****y**=**z**×**x****z**=**x**×**y**

Two of the best ways to change the UCS in AutoCAD are

- Rotate around a chosen axis: this is one of the more intuitive ways to adjust the current UCS when you don't have "pickable points" in the plane you want the new xy-plane to be in.
- Pick three points: this is a way to put the current UCS in line with a face or in line with somewhere you want to put a face. Lining up with an existing face of a 3D drawing only requires to you to pick three of the corners of the face. Depending on the order you pick those points in, you will get different directions for the axes,
*but*the xy-plane of the new UCS*will*coincide with the three points you pick.

To obtain consistent definitions for these axes we use the cross product (which I tried to sneak in earlier:

**z**=

**x**×

**y**). Here's the definition of the cross product:

**×**

*a***b**= (

*a*

_{2}b

_{3}- b

_{2}

*a*

_{3},

*a*

_{3}b

_{1}- b

_{3}

*a*

_{1},

*a*

_{1}b

_{2}-

*a*

_{2}b

_{1}),

where

**= (**

*a**a*

_{1},

*a*

_{2},

*a*

_{3}) and

**b**= (b

_{1}, b

_{2}, b

_{3}). Think about these vectors as direction vectors as opposed to points. One of the important properties of the cross product is that it produces a vector which is perpendicular to both of the vectors that form the product. That is,

**×**

*a***b**is perpendicular to

**and to**

*a***b**. To determine which way

**×**

*a***b**is pointing, point your fingers (using your right hand) in the direction of

*with your palm facing in a direction such that you can curl your fingers toward*

**a****b**. Your thumb is pointing in the direction of

**×**

*a***b**.

Here's how a UCS is defined based on three points. The first point (P

_{0}) indicates the position of the new origin. The second point (P

_{1}) defines the direction from the first point the x-axis goes in. So, the direction of the new x-axis is

**x**= P

_{1}− P

_{0}. The third point (P

_{2}) determines not only the plane, but also which side of the x-axis the y-axis will go (within the defined plane). At the same time, we are also defining, albeit indirectly, the direction of the z-axis by means of the right hand rule. We define our UCS accordingly:

- Origin: P
_{0} - x-axis:
**x**= P_{1}− P_{0} - z-axis:
**z**=**x**× (P_{2}− P_{0}) - y-axis:
**y**=**z**×**x**

**y**. Also observe that the order in which you select the points affects which way your axes are oriented, even though it will not affect what plane is the xy-plane of your new UCS. Given any three points, there are three possible origins - so I need to specify which is the origin. With that selected, I have two options for which will indicate the direction of my x-axis. So, there are six possible UCSs given the same three points in different orders.

Depending on the use of your UCS (if you are programming one in your own software) you may wish to normalize the direction vectors. Normalized vectors (which have length equal to unity) have some useful properties which may save some computation in later calculations. Normalizing is straightforward and simply requires you to divide the value of each component of the vector by the current length of the vector.

## No comments:

Post a Comment