DOT-OBJECTS - AN APPROACH!!

By Fizban/Compact

I guess you all have seen traditional vector-dot objects like "balls" etc. But how are the data for this kind of object made? Are they written down manually like in the average filled vector? Of course not! Who would have the patience to write down XYZ-data for a thousand+ dots? Here's where a couple of formulas come in handy... Let's imagine a sphere, it will, just like a globe, have both a longtitude and a latitude. The longtitude is the north-south direction of the sphere, while the latitude is the east-west direction. Both these numbers are from 0 to 360 degrees. This means that we'll need two numbers, written in degrees, to calculate the X,Y and Z position of the point.
And here's the formula:

D1= longtitude (Degree 1)
D2= latitude   (Degree 2)

X= Sin(D1)*Cos(D2)
Y= Sin(D1)*Sin(d2)'
Z= Cos(D1)

Let's have an example:
lea points,a0         ;points table
lea sinus,a1          ;sinus table
lea sinus+180,a2      ;cosinus table
move.l #10,d0         ;longtitude
move.l #56,d1         ;latitude
add    d0,d0          ;D0=Word pointer
add    d1,d1          ;D1=Word pointer          
move.w (a1,d0.w),d2   ;sin(d1)
muls   (a2,d1.w),d2   ;sin(d1)*cos(d2)
swap   d2             ;scale down
move.w d2,(a0)+       ;store x
move.w (a1,d0.w),d2   ;sin(d1)	
muls   (a1,d1.w),d2   ;sin(d1)+sin(d2)
swap   d2             ;scale down
move.w d2,(a0)+       ;store y
move.w (a2,d0.w),d2   ;cos(d1)
asr    #8,d2          ;scale down
move.w d2,(a0)+       ;store z
rts


Now you can start making a loop which calculates, let's say 1000 dots for this purpose you can use randomized numbers for long. and lat. or you can add with a constant for each point. When the dots are calculated you will of course have to rotate them. For this you use an ordinary rotate routine. I will not xplain the rotation in this article. This example was for a sphere, but with a little fantasy(and luck) you can create some weird objects. Let's say you instead of X=Sin(d1)*Cos(d2)use:X=Sin(d1+90)*Cos(D2+45)...
The possibilities are almost innfinitive. Once I managed to create a sort of a mug(?)...
So start experimenting!


Ripped from: Headline Issue #2