Monday, November 21, 2011

3D Analogue to the Trapezoid (part 2): Truncated Pyramid

Since I wrote the post entitled 3D Analogue to the Trapezoid, I have learned that people already have something in mind when they type in terms to this effect. They are interested in a truncated pyramid. In the aforementioned post, I described a shape, namely, an irregular triangular prism, that was analogous to a trapezoid in terms of its volume formula (the proof is located here). Now, we look at a shape that is analogous to a trapezoid in terms of its appearance, but has an only loosely analogous volume formula.


The first observation we might make is that pyramids are really not very different from cones from a volume perspective. The simple volume formula for both is given by

                                 clip_image004

where B is the area of the base and h is the height of the cone. This is true regardless of the shape of the base. The only requirement is that the same shape must continue all the way to the peak. In more technical language, the cross-section of the pyramid at distance b below the peak must be similar to the base and the corresponding linear dimensions must be in the ratio b:h. So, given a dimension of length d in the base, the corresponding dimension in the cross-section at b below the peak must have length d(b/h). This is part of the definition of a pyramid. At this point, a well-known, fancy theorem may be in order.

Theorem. Let A and B be similar (2-dimensional) shapes. Then,
Corresponding linear dimensions have a ratio of a:b if and only if the areas of A and B (or corresponding subareas) are in the ratio a2:b2.

In theorem form, this might seem like it’s from outer space, but notice how simply that works out with squares and circles. For example, if one square has a side of a and another of side b, then their areas are a2 and b2, respectively. The converse is obviously true as well, and it is the converse we will need.

Suppose we take the area of the top surface to be B1 and the area of the bottom surface to be B2. Also, take a to be the height of the part of the pyramid that has been removed and h to be the height of the truncated pyramid. Here’s a front orthographic view of the pyramid with the cut off part added back to the top:
                                     
                                   clip_image006

Our theorem then tells us that

                                         clip_image008

If we solve for a, we get

                                          clip_image010

The volume of our truncated pyramid is simply the volume of the full pyramid minus the volume of the part that has been cut off (truncated off):

                                         clip_image012
                                        clip_image014
                                        clip_image016
                                        
                                            clip_image020

It is noteworthy that we could have calculated a without calculating the areas B1 or B2. But we would need to know the ratio between a pair of corresponding sides, say d1 and d2 (see diagram below).

                                           
We would calculate a according to

                                                    clip_image024
which gives

                                                     clip_image026

Our volume formula will look a little nicer:

                                 clip_image028
                                    clip_image030
                                    clip_image032
                                    clip_image034
                                    clip_image036
                                    clip_image038
                                
                     
Letting r = d2/d1, we get


                             


The first volume formula makes somewhat of an analogy with the area formula of a trapezoid: We are taking the average (arithmetic mean) of
  1. the bottom base area,
  2. the top base area, and
  3. the geometric mean of the top and bottom areas
and multiplying by the perpendicular distance between the top and bottom areas. I must say, that’s a closer analogy than I expected before I wrote this article.

Saturday, November 19, 2011

Use IrfanView and Paint to Collate Multiple Scanned Picture

Recently I wanted to scan a drafting drawing in to allow me to trace it in AutoCAD instead of having to do so much hand scaling.  (For instructions on how to attach a raster image (like a scan) to an AutoCAD drawing, see here.)  But before I can do this tracing, I need to put the image together and there are some problems – for which I have found acceptable solutions.

Problem 1:  My scanner isn’t big enough to scan the whole drawing in one fell swoop. 

Solution 1:  Scan the document (in this case, the drawing) in several overlapping places.  Overlap is desirable to ensure proper matching of parts of the drawing.  Obviously, you must scan every part of the source document unless you are willing to make due without having certain parts of the drawing, or can fabricate such parts readily.


Problem 2:  The resulting scanned in images are crooked – meaning, they are at an angle.


Solution 2:  To straighten the images, you can use a free program called IrfanView – together with the IrfanView plugins.  After you have installed the program (don’t bother with the file associations steps in the install – choose no file associations; at least, that’s what I prefer so far):
  1. launch IrfanView and open up a picture you want to “straighten out.”
  2. determine the amount and direction of rotation necessary to correct the misorientation:
    1. hover mouse pointer over part of a line that is supposed to be horizontal (or vertical) – aim for the middle of the thickness of the line and an extreme end (left, right, top, or bottom)
    2. press and hold left mouse button
    3. with the left button still depressed, move mouse pointer over to the opposite end of the same line (or one which is supposedly aligned with it)
    4. when pointer is over the center of the thickness of the opposite end of the line (or other chosen destination), release the left mouse button
    5. in the title bar, you will see some information:
      1. blah blah blah (Selection: x_position, y_position; x_dim x y_dim; blah)
      2. we need the x_dim and y_dim (as in, dimension)
    6. Calculate tan-1(x_dim/y_dim) or tan-1(y_dim/x_dim); choose the option with the smaller of x_dim or y_dim in the numerator.  You will use a positive number if you need to rotate clockwise or take the negative of the number if you need to rotate counter-clockwise.
  3. go to the image menu and select Custom/Fine rotation…
  4. Select a background color for infill.  When the picture is rotated, it will leave a blank space.  This blank space can’t just be blank per se – it needs to have some color or other.  Here is where you select that color.
  5. Enter the number of degrees to rotate – use the value and sign determined in step 2.6.
The rest of the process is straightforward, albeit tedious and can be done in most picture editing software, including MS Paint.  Open the destination image up and enlarge it.  Open the source files (one at a time) and select all, copy.  Then paste those images into the destination image file and move the image around as desired.  It may take a bit of thinking and practice to feel comfortable with the process.  This will not get you beautiful results most of the time, but it can produce a picture to trace over with a proper drawing or drafting program.