PDA

View Full Version : Generating 3D plotting points.


docerido
06-07-2005, 11:30 AM
Hi,

I have been trying to create an equation to plot points (perspective projection style) for wireframe shapes. I need to start with 4 points and go up to an unlimited number creating geodesic forms and need to do this dynamically. I have been trying various things to do this for me and am now at the stage of dreaming in sine and cosine wavelengths! :)

I have found co-ordinates for two forms and need an equation that would generate this kind of data.

For example a 3sided pyramid co-ordinate points are - (4 points)
-0.212331, -58.3687, -82.3175,
82.3334, 58.3686, 0.228231,
-82.7581, 58.3686, 0.228231,
0.212331, -58.3686, 82.774

and a square's are: (8 points)
-150, -150, -150,
-150, 150, -150,
150, 150, -150,
150, -150, -150,
150, -150, 150,
-150, -150, 150,
-150, 150, 150,
150, 150, 150

I was wondering if anyone has come accross a 3D plotter which would create a wireframe starting with just 4 points... or idealy someone who is just brilliant at maths and knows how to do this! ;)

Thanks all!

suisei
06-08-2005, 07:50 AM
im not sure if there is any tutorals on this site for this. come tho think of it a dont know if this is what you want.but..
first take a look at the swf and then if its what you want go to the link and look at the tutorials.

its where i started from

http://www.bit-101.com/

docerido
06-08-2005, 12:32 PM
Great link! some really nice stuff....

I did the 3D rotation tutorial but it isnt acctually placing any objects. Its dealing just with the one object you place the script in. Is this the tutorial you used to produce your swf? Yours looks like it could possibly be what im looking for. have you extended the tutorials capability - are the spheres dynamically placed through a formula in your code?

Thanks! :)

docerido
06-08-2005, 05:24 PM
okay - its just an x y z coordinate generator i'm looking for. any ideas on this. I have found a sideline solution by creating the shape in Rhino then finding the xyz coordinates for each point. There must be a way to do this automatically using trigonometry?

suisei
06-09-2005, 01:52 AM
this is the code for the movie which is mainly from the studies of the site above and most other work on 3d in flash. this is the basic foundation which i learnt (often copied) which i altered later to make different things like working with shadow colour change adding to the shape while the movie plays.etc

xM =250;
yM =200;
zM = 200;
fl =250;

spacing =100;
count = 0;
yD = 5;
xD = 5;
cosx = Math.cos(xD);
sinx = Math.sin(xD);
cosy = Math.cos(yD);
siny = Math.sin(yD);
for(x=0;x<2;x++){
for(y=0;y<2;y++){
for(z=0;z<2;z++){
ball = attachMovie("ball", "ball_" + x + "_" + y + "_" + z, count++);
ball.x = (.5 + x)* spacing;
ball.y =(.5 + y)* spacing;
ball.z =(.5 + z)* spacing;
ball.onEnterFrame=move;
}
}
}
function move(){
var x1 = this.x * cosy - this.z * siny;
var z1 = this.z * cosy + this.x * siny;
var y1 = this.y * cosx - z1 * sinx;
var z2 = z1 * cosx + this.y * sinx;
this.x = x1;
this.y = y1;
this.z = z2;
var scale = fl/(fl + this.z + zM<);
this._x = this.x * scale + xM;
this._y = this.y * scale + yM;
this._xscale = this._yscale = scale * 100;
this.swapDepths(100000 - (this.z + Math.random()) * 1000);

}


onEnterFrame = function(){
yD = (_xmouse - 270)*.0005;
cosy = Math.cos(yD);
siny = Math.sin(yD);
xD= (_ymouse - 200)*.0005;
cosx = Math.cos(xD);
sinx = Math.sin(xD);
}

thats a mouth full :eek:

the top variables
xM+yM control the coordinates ,relative to the movie size, in which the balls "orbit" around.
zM controls the depths eg the lower the number the closer to the sceen.
ball.x = (.5 + x)* spacing; the .5 here means the first ball is slightly away from the orbit point. if you take this number out it will look more like the other balls are rotating around this one.

the Math.cos Math.sin etc are all to do with trigonometry so ill leave that for someone else to explain or for another time. ;)

anyway help with that and with the trignometry can be found on the link above.

good luck