avatar tianjara.net | blog icon Andrew Harvey's Blog

Entries from November 2008.

A Custom Drawing Projections Tool
29th November 2008

Back in 2007 I developed a software tool that could generate technical drawings in a range of drawing projections from a 3D model with emphasis on oblique (both cabinet and cavalier, as well as custom obliques), planometric, dimetric, trimetric and one-point perspective.

I could describe them all as well as many more in terms of what the projected three axis look like on the projection plane. I described them all in terms of a scale on each of the three axis, as well as the angle two of the axis make with the projection plane's horizontal.

[caption id="attachment_130" align="aligncenter" width="151" caption="Description of the projection in terms of the projected view of the three standard basis."]Description of the projection in terms of the projected view of the three standard basis.[/caption]

In terms of the actual development of the program I'm sure I could have done things a lot better. But I did learn a lot from the experience. The program worked to my needs and did what I wrote it to do so in that sense it was a success. The only downside would be that I did a lot of code rewriting of code that already existed out there (which probably did thinks better than I implemented them). Although since then I have done much more programming and had formal training so have learnt about better methods and practices.

The approach I took was basically import a DXF file, process the data to change its projection, and then export it as a DXF again. I used 3D polylines generated from my 3D model in Rhino and saved as DXF for the input. So I had to write a cutdown DXF reader/writer, as well as a way of storing this data internally and then doing the transformations on it then exporting it back into DXF so I could open it up in AutoCAD.

I only supported points, polylines, circles and arcs as this is basically all that Rhino exported from my model. To simplify the process of circles and arcs I internally converted them to a bunch of polylines as only for some projections they stayed as nice ellipses.

[caption id="attachment_104" align="aligncenter" width="961" caption="The user interface of the tool."]The user interface of the tool.[/caption]

From a very simple model in Rhino, I use the silhouette tool to create the polylines which once impororted into my program produced the following samples.

[caption id="attachment_131" align="aligncenter" width="152" caption="Cabinet Oblique"]Cabinet Oblique[/caption]

[caption id="attachment_132" align="aligncenter" width="205" caption="Cavalier Oblique"]Cavalier Oblique[/caption]

[caption id="attachment_133" align="aligncenter" width="184" caption="Planometric"]Planometric[/caption]

[caption id="attachment_134" align="aligncenter" width="180" caption="One Point Perspective"]One Point Perspective[/caption]

There is also a range of built in axonometric projections...

[caption id="attachment_105" align="aligncenter" width="450" caption="A range of axonometric projections are built in."]A range of axonometric projections are built in.[/caption]

Finally here are some of my production drawings (from my 2007 HSC ITG Major Work (photos here)) that I used the software to create.

[caption id="attachment_135" align="aligncenter" width="450" caption="Oblique"]Oblique[/caption]

[caption id="attachment_136" align="aligncenter" width="450" caption="One Point Perspective"]One Point Perspective[/caption]

[caption id="attachment_137" align="aligncenter" width="450" caption="Planometric"]Planometric[/caption]

[caption id="attachment_138" align="aligncenter" width="450" caption="Trimetric"]Trimetric[/caption]

Tags: industrial technology, projections, technical drawing.
Google's Search Experiment: Keyboard Shortcuts
23rd November 2008

A few weeks ago I noticed one of Google's search experiments, keyboard shortcuts. I really like this feature and hope it graduates from experiment status however one small thing I noticed is that (at least for me) makes me more willing to click on googles ads. When I did a Google search with no keyboard shortcuts I would just skill over the ads and go straight to the results, but now with keyboard shortcuts turned on the default position of the "cursor" (actually and arrow) is at the top pointing to ads (if there are any). This distracts me to look at the ad and more likely to visit it.

Additionally in the case where the first result is the same as the top add, where I would previously just go straigh to the main link, with shortcuts its easier to just press enter with the cursor on the ad. The two diagrams below show this.

[caption id="attachment_126" align="aligncenter" width="450" caption="Google search with keyboard shortcuts. Notice that the top ad and the 1st result are (almost) the same. But since its easier to press Enter than J then Enter I am more likely to go to the ad...."]google-keyboard-crop[/caption]

[caption id="attachment_127" align="aligncenter" width="450" caption="... however in the classical view I would just click on the 1st regular link with the mouse as its just as easy to click the non-ad vs. the ad."]... however in the classical view since I'm moving the mouse I would just click the non-ad first link.[/caption]

Tags: google.
The Mathematics Behind Graphical Drawing Projections in Technical Drawing
15th November 2008

In the field of technical drawing, projection methods such as isometric, orthogonal, perspective are used to project three dimensional objects onto a two dimensional plane so that three dimensional objects can be viewed on paper or a computer screen. In this article I examine the different methods of projection and their mathematical roots (in an applied sense).

The approach that seems to be used by Technical Drawing syllabuses in NSW to draw simple 3D objects in 2D is almost entirely graphical. I don't think you can say this is a bad thing because you don't always want or need to know the mathematics behind the process, you just want to be able to draw without thinking about this. However to have an appreciation of what's really happening the mathematical understanding is a great thing to learn.

Many 3D CAD/CAM packages available on the market today (such as AutoCAD, Inventor, Solidworks, CATIA, Rhinoceros) can generate isometric, three point perspective or orthogonal drawings from 3D geometry, however from what I've seen they can't seem do other projections such as dimetric, trimetric, oblique, planometric, one and two point perspective. Admittedly I don't think these projections are any use or even needed, but when your at high school and you have to show that you know how do to oblique, et al. it can be a problem when the software cannot do it for you from your 3D model. (So I actually wrote a small piece of software to help with this in this article). But to do so, I needed to understand the mathematics behind these graphical projections. So I will try to explain that here.

The key idea is to think of everything having coordinates in a coordinate system (I will use the Cartesian system for simplicity). We can then express all these projections as mathematical transformations or maps. Like a function, you feed in the 3D point, and then you get out the projected 2D point. Things get a bit arbitrary here because an isometric view is essentially exactly the same as a front view. So we keep to the convention that when we assign the axis of the coordinate system we try to keep the three planes of the axis parallel to the three main planes of the object.

[caption id="attachment_107" align="aligncenter" width="450" caption="The three "main" planes of the object are placed parallel to the three planes of the axis. This is how we will choose our axis in relation to the object."]The three "main" planes of the object are placed parallel to the three planes of the axis. This is how we will choose our axis in relation to the object.[/caption]

We will not do this though,

[caption id="attachment_108" align="aligncenter" width="450" caption="We will not choose it like this..."]We will not choose it like this...[/caption]

[caption id="attachment_109" align="aligncenter" width="450" caption="...or this."]...or this.[/caption]

In fact doing something like that shown just above with the object rotated is how we get projections like isometric.

Now what we do is take the coordinates of each point and "transform" them to get the projected coordinates, and join these points with lines where they originally were. However we can only do this for some kinds of projections, indeed for all the ones I have mentioned in this post this will do but only because these projections have a special property. They are linear maps (affine maps also hold this property and are a superset of the set of linear maps) which means that straight lines in 3D project to straight lines in 2D.

For curves we can just project a lot of points on the curve (subdivide it) and then join them up after they are projected. It all depends what our purpose is and if we are applying it practically. We can generate equations of the projected curves if we know the equation of the original curve but it won't always be as simple. For example circles in 3D under isometric projection become ellipses on the projection plane.

Going back to the process of the projection, we can use matrices to represent these projections where

$latex \begin{pmatrix}x'\\ y'\\ z'\end{pmatrix} = \begin{pmatrix}a&b&c\\ d&e&f\\ g&h&i\end{pmatrix}\begin{pmatrix}x\\ y\\ z\end{pmatrix}$

is the same as,

$latex x' = ax+by+cz\\ y' = dx+ey+fz\\ z' = gx+hy+iz.$

We call the 3 by 3 matrix above as the matrix of the projection.

Knowing all this, we can easily define orthogonal projection as you just take two of the dimensions and cull the third. So for say an orthographic top view the projection matrix is simply,

$latex \begin{pmatrix}1&0&0\\ 0&1&0\\ 0&0&0\end{pmatrix}.$

Now we want a projection matrix for isometric. One way would be to do the appropriate rotations on the object then do an orthographic projection, we can get the projection matrix by multiplying the matrices for the rotations and orthographic projection together. However I will not detail that here. Instead I will show you another method that I used to describe most of the projections that I learnt from high school (almost all except perspectives).

I can describe them as well as many "custom" projections in terms of what the three projected axis look like on the projection plane. I described them all in terms of a scale on each of the three axis, as well as the angle two of the axis make with the projection plane's horizontal.

[caption id="attachment_112" align="aligncenter" width="151" caption="Projection attributes described in terms of the projected axis."]Projection attributes described in terms of the projected axis.[/caption]

Using this approach we can think of the problem back in a graphical perspective of what the final projected drawing will look like rather than looking at the mathematics of how the object gets rotated prior to taking an orthographic projection or what angle do the projection lines need to be at in relation to the projection plane to get oblique, etc. Note also that the x, y, z in the above diagram are the scales of the x, y, z axis respectively. So we can see in the table below that we can now describe these projections in terms of a graphical approach that I was first taught.

Projection α (alpha) β (beta) Sx Sy Sz
Isometric 30° 30° 1 1 1
Cabinet Oblique 45° 0.5 1 1
Cavalier Oblique 45° 1 1 1
Planometric 45° 45° 1 1 1

Now all we need is a projection matrix that takes in alpha, beta and the three axes scale's and does the correct transformation to give the projection. The matrix is,

$latex \begin{bmatrix}x'\\y'\\z'\\1\end{bmatrix}=\begin{bmatrix}S_x\cos\alpha&-S_y\cos\beta&0&0\\ S_x\sin\alpha&S_y\sin\beta&S_z&0\\ 0&0&0&0\\ 0&0&0&1\end{bmatrix}\begin{bmatrix}x\\y\\z\\1\end{bmatrix}$

Now for the derivation. First we pick a 3D Cartesian coordinate system to work with. I choose the Z-up Left Hand Coordinate System, shown below and we imagine a rectangular prism in the 3D coordinate system.

[caption id="attachment_114" align="aligncenter" width="450" caption="Block in 3D coordinate system."]Block in 3D coordinate system.[/caption]

Now we imagine what it would look like in a 2D coordinate system using isometric projection.

[caption id="attachment_115" align="aligncenter" width="450" caption="Block in 2D coordinate system (isometric)."]Block in 2D coordinate system (isometric).[/caption]

As the alpha and beta angles (shown below) can change, and therefore not limited to a specific projection, we need to use alpha and beta in the derivation.

pp-description

Now using these simple trig equations below we can deduce the following.

polar

All the points on the xz plane have y = 0. Therefore the x’ and y’ values on the 2D plane will follow the trig property shown above, so:

$latex x'=x\cos\alpha$ $latex y' = z + y\sin\alpha$

However not all the points lie on the xz plane, y is not always equal to zero. By visualising a point with a fixed x and z value but growing larger in y value, its x’ will become lower, and y’ will become larger. The extent of the x’ and y’ growth can again be expressed with the trig property shown, and this value can be added in the respective sense to obtain the final combined x’ and y’ (separately).

$latex x'=x\cos\alpha -y\cos\beta$ $latex y' = z + x \sin \alpha + y \sin \beta$

If y is in the negative direction then the sign will automatically change accordingly. The next step is to incorporate the scaling of the axes. This was done by replacing the x, y & z with a the scale factor as a multiple of the x, y & z. Hence,

$latex x'=S_x x\cos\alpha -S_y y\cos\beta$ $latex y' = S_z z + S_x x\sin\alpha + S_y y \sin \beta$

This can now easily be transferred into matrix form as shown at the start of this derivation or left as is.

References: Harvey, A. (2007). Industrial Technology - Graphics Industries 2007 HSC Major Project Management Folio. (Link)

Tags: graphics, mathematics, projections, technical drawing.

RSS Feed