Friday, April 1, 2011

Excel automation


Lets put what we already know into practice :
Example 1
This is our example .  Quite simple it is, but it will show every step and because all the points have integer coordinates it is simple to control calculation steps. 

Distances between points
From point coordinates we can calculate distances as on the picture to the left . All the diagonal lines have the same length .
r1 , r2 , r3 and r4 for first pair of points
For calculation of first pair of points we define r1, r2 , r3 and r4 , as on a picture to the left .



r1 , r2 , r3 and r4 for second pair of points
For a second pair we do the same  and we can see all the marked lines on a picture .













Developed surface from example 1
As a result we should get unrolled surface with a point coordinates as on a picture .
Formulas
All the calculations we perform in spreadsheet ( Excel , OpeOffice.org Calc or another ).
This is a simple version of such a spreadsheet .
You can see the formulas , and below i will give explanation of all of them .
Only first line is inputted, rest of the formulas will be automatically inputted using fill handle .








Cell A3 : Point number
Cells B3-D3 : Coordinates of points in curve A
Cells E3-G3: Coordinates of points in curve A
Cell H3 : Distance between point A1 and A2 [r1]
Cell I3 : Distance between point A2 and B1 [r2]
Cell J3 : Distance between point A1 and B1 [D]
Cell K3 : Difference between x coordinates of points A'1 and B'1 [Dx]
Cell L3 : Difference between y coordinates of points A'1 and B'1 [Dy]
Cell M3 : Value of a based on r1, r2 and D [a]
Cell N3 : Value of h based on r1and a [h]
Cell O3 : Distance between point A2 and B2 [r3]
Cell P3 : Distance between point B1 and B2 [r4]
Cell Q3 : Distance between point A2 and B1 [D]
Cell R3 : Difference between x coordinates of points A'2 and B'1 [Dx]
Cell S3 : Difference between y coordinates of points A'2 and B'1 [Dy]
Cell T3 : Value of a based on r3, r4 and D [a]
Cell U3 : Value of h based on r3and a [h]
Cells V3-X3 : Starting point of developed surface (coordinates x, y, z) [point A'1]
Cells Y3-AA3 : point B'1 , coordinate  x = coordinate x of point A'1 plus value D from cell J3
                         Coordinates y and z are the same as of point A'1
Cells V4-X4 : Coordinates x and y of point A'2 , based on r1 , r2 , h , a , Dx , Dy and D.
                       Coordinate z is the same as z of point A'1
Cells Y4-AA4 : Coordinates x and y of point B'2 , based on r3 , r4 , h , a , Dx , Dy and D.
                       Coordinate z is the same as z of point B'1

Calculated example 1
Our example calculated with a spreadsheet .
We can of course expand our spreadsheet for more points, and add for example an preview of developed surface .
Example 2 . 
Curves, points, triangles, surface and developed surface
Here we can see two definition curves as a splines, points generated on the curves , triangles spanned on the points , generated surface and developed surface .
Coordinates of the points were exported to excel file , and then inputted into our spreadsheet .
Then calculated developed point were exported and on base of those was developed surface drawn .

Calculated example 2

To be continued ...


No comments:

Post a Comment