Showing posts with label Developing. Show all posts
Showing posts with label Developing. Show all posts

Tuesday, July 5, 2011

Good bye Excel , Welcome Ruby

SEE THIS POST IN POLISH
So... Here comes the time, when you have to lower your head and admit: I was wrong.

I was wrong, thinking that Excel or other calculation sheet will be the most universal way to unroll parts...

I was also wrong, thinking that learning another programming language is a bit too much...

I am wrong and probably will be wrong on several occasions, but the work continues , but this time only in Sketchup and in RUBY :


To Be Continued

Żegnaj Excelu , witaj Ruby

SEE THIS POST IN ENGLISH
No tak... nadhodzi taka chwila ,że trzeba pochylic głowę z pokorą i powiedzieć: Pomyliłem się.

Pomyliłem się, myśląc że Excel, albo inny arkusz kalkulacyjny będzie najbardziej uniwersalnym narzędziem do rozwijania...

Pomyliłem się , myśląc że kolejny język programowania którego trzeba się nauczyć, to przesada...

Prawdopodobnie mylę się i będę się mylił jeszcze w wielu sprawach, ale praca dalej idzie do przodu, tym razem jednak wyłącznie w Sketchupie i RUBY :

CDN.

Sunday, May 22, 2011

Video !!! How it works so far.

SEE THIS POST IN POLISH
Welcome again.
It has been a while, but I am back online.
So today a small preview of how it works so far.No voice over - My voice just sounds strange :D
First video is pure Sketchup.
We have 2 definition curves created with Bezier curves.
Note that precision of both curves is set to the same value (50 parts).
There is also another closed curve that will be used as a definition of camouflage.
First we create our surface with another ruby script - skin.
You can see what settings I used.
Then we pull our camouflage definition, and create intersection with our surface.
When cleared from all not necessary parts we can see camo lines on our surface.
Next part is to export points to a files, one for top curve, one for bottom curve and one for all camo points.



Second video is first part of excel calculations.
First we import points for definition curves. On a preview you can see that points are numbered and this will be used for sorting. Calculations are made in a way that curves should go anticlockwise. So our starting point is at bottom, and first point should be where nor point 51 is.Next point would be where now 50's are. Also You can see at the top that on curve 2 ( blue ), there is something wrong ( look at the points 2,1 and 3)
So we go back to curves input , and set points nr 51 on both curves as 1 and points 50 as 2 , after resorting points on first curve You can seethe effect ( best on 3d preview).
Resorting second curve gets us our developer surface.
We can import camouflage line points.
(Error message occurs because there is no points data available.)
We run a macro to develop points onto surface , and after some time we get all points developed.
Time it takes is dependent on number of points to develop and number of points on definition curves.
When all calculations are done we can export all points to CSV file to get it to Sketchup again.


Third part next time.

Friday, April 15, 2011

Progress with work

SEE THIS POST IN POLISH

Not so much time to write here, but it is steady going forward.

Sheet 1 - Definition curves data.








Sheet 1 - Development Preview, Definition curves in head view and in axonometry.
Sheet 2 - More detailed head-on view of definition curves . This will be used to properly orientate our part . 
 






Sheet 3 - Input data for points on the surface .








Sheet 3 - Preview of surface points in axonometry .
 Sheet 3 - Preview of developed surface points .
In fact it s possible to export this data to Sketchup and draw an developed element . But at this moment there is no Sketchup plugin to automatically fit curve to set of points , so You would have to draw an curve point by point.
At this moment work is concentrated on work arount for this .

To be continued . . .

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 ...


Monday, March 28, 2011

From 3D to 2D with algebra


To write a developing algorithm we need to get familiar with 2 topics from mathematical algebra .

3D coordinates and length of triangle sides
First we need to know all 3 sides of triangle .
A triangle can be defined with 3 points . And every point can be described with 3 coordinates (x,y,z) .
Distance between two points is equal to square root from sum of squared differences between point coordinates . See picture .




Construction
 Next step is made in 2 dimensions . First we define a line between two points A and B . distance between those points is equal to length of a first side of triangle ( D on a picture ) . Other sides of a triangle have lengths of  r1 and  r2 . We are looking for point C with coordinates (xC; yC) .

First step is to find point S .
From Pythagorean theorem for triangles ACS and BCS we:get :
r1² = h² + a²
r2² = h² + b²
From difference between those two equations :
r1² - r2² = a² - b²
r1² -r2² = (a+b) * (a-b)
And because D = a + b  and  b = D - a
r1² -r2² = D * (2a-D)
Therefore :
a = (r1² -r2² +D²) / 2D

Point S has coordinates :
xS = x1 + (Dx * a) / D
yS = y1 + (Dy * a) / D

When we know a we can also calculate h : h = √(r1² - a²)
we can also write down two dependencies :
Dy / D = dx / h  =>  dx = - (Dy * h ) / D
( negative sign tells us that if Dy is positive(point B is above point A), then point C is to the left from point S and vice-verso )
Dx / D = dy / h  =>  dy = (Dx * h ) / D

Last step is getting coordinates of point C :
xC = xS + dx = x1 + (Dx * a) / D - (Dy * h ) / D = x1 + (Dx * a - Dy * h ) / D
yC = yS + dy = y1 + (Dy * a) / D + (Dx * h ) / D = y1 + (Dy * a + Dx * h ) / D

There is also second possible point C' that is situated below line AB
xC' = xS + dx = x1 + (Dx * a) / D + (Dy * h ) / D = x1 + (Dx * a + Dy * h ) / D
yC' = yS + dy = y1 + (Dy * a) / D - (Dx * h ) / D = y1 + (Dy * a - Dx * h ) / D

To be continued ...

Friday, March 25, 2011

My unrolling theory

ZOBACZ TEN POST PO POLSKU

A developable surface is a ruled surface which in every point has a Gaussian curvature equal to 0 .

That is a definition. In fact that means that developable surface can be developed to a plane without stretching or cutting .
 
Cone side development .

An example can be side of a cone or a cylinder .
You can also say that cone is an pyramid with an infinite number of base sides .Cylinder is a prism with an infinite count of base sides . That means that every prism or pyramid can be developed .
That leads to the conclusion that surface is developable if it consist from multiple flat surfaces , and every surface is connected to others with not more than 2 sides .

Surfaces spanned between spline an arc,
and polylines that interpolate basic curves.
Surfaces modelled with quads and triangles.
So if You have two curves, You can interpolate it with a polylines with the same sides count . On these polylines You can create a surface that consist from multiple quadrangles .
But not every quadrangle must be flat . To solve this problem, You can divide every quadrangle into two triangles , which solves the problem because every triangle is a flat figure .

How to develop 3-dimensional triangulated surface ?


Definition curves, spanned surface and it's development .

We have 2 polylines that will define our surface, lets mark their points with A1-A5 and B1-B5 .
Create a triangulated surface spanned on those 2 polylines ( see picture to the left ) . Such a surface you can develop using simple geometrical construction.
Construction  of a triangle using 3 known sides .
If You know length of all 3 sides of a triangle , You can draw one side , and then draw from both ends arcs with a radios equal to length of other sides . Intersection between those arcs gives You third point of a triangle. If You repeat the same construction for every triangle , in the end You get a developed surface .




Next task is to make the whole process automatic ?

To be continued ...