# 3D Polar Revolution

**URL:** <https://forum.kirupa.com/t/3d-polar-revolution/185736>\
**Category:** open source\
**Created:** [April 15, 2006, 11:59pm UTC](https://forum.kirupa.com/t/3d-polar-revolution/185736 "2006-04-15T23:59:28Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![freeskier89](https://avatars.discourse-cdn.com/v4/letter/f/f475e1/32.png) [@freeskier89](https://forum.kirupa.com/u/freeskier89)\
**Post date:** [April 15, 2006, 11:59pm UTC](https://forum.kirupa.com/t/3d-polar-revolution/185736/1 "2006-04-15T23:59:28Z")

</div>

Hello,

I just thought I would share my latest experiment with you 🙂 It has been a while since I have messed with 3d so I thought it was about time. Here a basic 3D engine is set up and then movieclips revolve three dimensionally around the center (0,0,0) using some pretty basic math.

```auto
Camera=function(X,Y,Z,focalLength){
 this.fL=focalLength;
 this.X=X;
 this.Y=Y;
 this.Z=Z;
 }
Camera.prototype.Move=function(X,Y,Z){
 this.X+=X;
 this.Y+=Y;
 this.Z+=Z;
 this.engine.Render();
 }
Engine3D=function(Camera,Centerx,Centery){
 this.camera=Camera;
 this.camera.engine=this;
 this.vertexBuffer = _root.createEmptyMovieClip("3Dcontainer"+(containerdepth++),containerdepth);
 this.vertexBuffer._x=Centerx;
 this.vertexBuffer._y=Centery;
 this.depth=0;
 }
Engine3D.prototype.Render=function(){
 for(i in this.vertexBuffer){
  this.vertexBuffer*.Draw();
  }
 }
Engine3D.prototype.Attach3DPoint=function(X,Y,Z){
 this.depth++;
 var mc=this.vertexBuffer.attachMovie("point","point"+this.depth,this.depth);
 mc.parentEngine=this;
 mc.X=X;
 mc.Y=Y;
 mc.Z=Z;
 mc.Draw();
 return mc;
 }
MovieClip.prototype.Draw=function(){
  var focalRatio=this.parentEngine.camera.fL/(this.parentEngine.camera.fL+(this.Z-this.parentEngine.camera.z))
  this._x=focalRatio*(this.parentEngine.camera.X-this.X);
  this._y=focalRatio*(this.parentEngine.camera.Y-this.Y);
  this.swapDepths(10000-this.Z);
  this._xscale=this._yscale=this._alpha=focalRatio*100;
 }
Camera1 = new Camera(0,0,-20,70);
Engine1=new Engine3D(Camera1,150,150);
//These are the variables that you will want to manipulate
Radius = 1;
Count=5;
OutwardVelocity =.1
RotationalVelocity =.015;
UpwardVelocity=3;
_root.createEmptyMovieClip("line",-1);
for(var n = 0;n<Count;n++){
 var mc = Engine1.attach3DPoint(0,0,0);
 mc.T=n/Count*Math.PI*2;
 
 mc.a=1+Math.random()*5;
 mc.b=1+Math.random()*5;
 mc.c=1+Math.random()*5;
 
 mc.R=50;
    mc.line=line.createEmptyMovieClip("line"+n,n+1);
 mc.line.lineStyle(1,0,100);
 mc.line.moveTo(mc.parentEngine.vertexBuffer._x,mc.parentEngine.vertexBuffer._y);
 mc.onEnterFrame=function(){
  this.T+=RotationalVelocity;
  this.X=this.R*Math.cos(this.T*this.a)*Math.sin(this.T);
  this.Z=this.R*Math.sin(this.T*this.b)*Math.sin(this.T);//this.Z;
  this.Y=this.R*Math.sin(this.T*this.c)*Math.sin(this.T);//UpwardVelocity*=.995//this.R*Math.sin(this.T);//1//this.Z;
  }
 }
onEnterFrame=function(){
 Engine1.Render();
 }

```

---

<div class="post-metadata">

**Author:** ![Icehawk](https://avatars.discourse-cdn.com/v4/letter/i/51bf81/32.png) [@Icehawk](https://forum.kirupa.com/u/Icehawk)\
**Post date:** [April 16, 2006, 1:01am UTC](https://forum.kirupa.com/t/3d-polar-revolution/185736/2 "2006-04-16T01:01:33Z")

</div>

why not just use tweens as well as motion guides 🙂  
be alotttt easier

---

<div class="post-metadata">

**Author:** ![freeskier89](https://avatars.discourse-cdn.com/v4/letter/f/f475e1/32.png) [@freeskier89](https://forum.kirupa.com/u/freeskier89)\
**Post date:** [April 16, 2006, 1:23am UTC](https://forum.kirupa.com/t/3d-polar-revolution/185736/3 "2006-04-16T01:23:03Z")

</div>

> [@Icehawk](#):
>
> why not just use tweens as well as motion guides 🙂  
> be alotttt easier

I beg to differ.

1. Any sort of flexibility would be lost.
2. I think writing about an hours worth of code is _much_ more enjoyable than working with _cough_ tweens.
3. Please try to tween the same effect and I would **love** see what you come out with :D.
4. Just plain \> :lol:

[whisper]Are you serious?[/whisper]

Edit: Here is what the motion guides would look like! Have fun drawing them :). (They were drawn with CODE).

---

<div class="post-metadata">

**Author:** ![fenrir](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@fenrir](https://forum.kirupa.com/u/fenrir)\
**Post date:** [April 16, 2006, 5:28am UTC](https://forum.kirupa.com/t/3d-polar-revolution/185736/4 "2006-04-16T05:28:23Z")

</div>

Yeah, really. You kinda missed the point (and the significance!) of what he’s got there, Icehawk. Don’t take it for just what you see in his example, think about the script.

Btw, pretty cool thing ya got there, freeskier89!

-Fenrir

---

<div class="post-metadata">

**Author:** ![theflash](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/theflash/32/1221_2.png) [@theflash](https://forum.kirupa.com/u/theflash)\
**Post date:** [April 16, 2006, 5:39pm UTC](https://forum.kirupa.com/t/3d-polar-revolution/185736/5 "2006-04-16T17:39:25Z")

</div>

nice piece of code… good work…

---

<div class="post-metadata">

**Author:** ![Pattt](https://avatars.discourse-cdn.com/v4/letter/p/f1d935/32.png) [@Pattt](https://forum.kirupa.com/u/Pattt)\
**Post date:** [April 16, 2006, 6:18pm UTC](https://forum.kirupa.com/t/3d-polar-revolution/185736/6 "2006-04-16T18:18:52Z")

</div>

Too good! :stare:

---

<div class="post-metadata">

**Author:** ![Jeff\_Wheeler](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@Jeff\_Wheeler](https://forum.kirupa.com/u/Jeff_Wheeler)\
**Post date:** [April 16, 2006, 9:48pm UTC](https://forum.kirupa.com/t/3d-polar-revolution/185736/7 "2006-04-16T21:48:02Z")

</div>

Neat :thumb:

---

<div class="post-metadata">

**Author:** ![Seb\_Hughes](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@Seb\_Hughes](https://forum.kirupa.com/u/Seb_Hughes)\
**Post date:** [April 16, 2006, 9:51pm UTC](https://forum.kirupa.com/t/3d-polar-revolution/185736/8 "2006-04-16T21:51:38Z")

</div>

Very Nice, I usally code stuff like that in 5 mins before i go to bed :lol:, I cant even code AS 😛 :run:

---

<div class="post-metadata">

**Author:** ![Jeff\_Wheeler](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@Jeff\_Wheeler](https://forum.kirupa.com/u/Jeff_Wheeler)\
**Post date:** [April 16, 2006, 9:54pm UTC](https://forum.kirupa.com/t/3d-polar-revolution/185736/9 "2006-04-16T21:54:36Z")

</div>

I code best in the middle of the night…

---

<div class="post-metadata">

**Author:** ![freeskier89](https://avatars.discourse-cdn.com/v4/letter/f/f475e1/32.png) [@freeskier89](https://forum.kirupa.com/u/freeskier89)\
**Post date:** [April 16, 2006, 10:00pm UTC](https://forum.kirupa.com/t/3d-polar-revolution/185736/10 "2006-04-16T22:00:53Z")

</div>

Thanks guys! Here is another little add on. I am thinking that a 3d Fractal Tree is in order in the near future :D.

---

<div class="post-metadata">

**Author:** ![Jeff\_Wheeler](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@Jeff\_Wheeler](https://forum.kirupa.com/u/Jeff_Wheeler)\
**Post date:** [April 16, 2006, 10:11pm UTC](https://forum.kirupa.com/t/3d-polar-revolution/185736/11 "2006-04-16T22:11:24Z")

</div>

That’s really neat, too. For some reason it’s way off to the top right… ☹

---

<div class="post-metadata">

**Author:** ![freeskier89](https://avatars.discourse-cdn.com/v4/letter/f/f475e1/32.png) [@freeskier89](https://forum.kirupa.com/u/freeskier89)\
**Post date:** [April 16, 2006, 10:38pm UTC](https://forum.kirupa.com/t/3d-polar-revolution/185736/12 "2006-04-16T22:38:20Z")

</div>

Try moving your mouse :thumb:. It now positions the camera based on the cursor.

---

<div class="post-metadata">

**Author:** ![gvozden](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/gvozden/32/1084_2.png) [@gvozden](https://forum.kirupa.com/u/gvozden)\
**Post date:** [April 16, 2006, 10:45pm UTC](https://forum.kirupa.com/t/3d-polar-revolution/185736/13 "2006-04-16T22:45:48Z")

</div>

last example shows better what you got there  
really nice

---

<div class="post-metadata">

**Author:** ![Jeff\_Wheeler](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@Jeff\_Wheeler](https://forum.kirupa.com/u/Jeff_Wheeler)\
**Post date:** [April 16, 2006, 11:05pm UTC](https://forum.kirupa.com/t/3d-polar-revolution/185736/14 "2006-04-16T23:05:38Z")

</div>

Oh, I see. I feel dumb, now. :lol:

---

<div class="post-metadata">

**Author:** ![rmo518](https://avatars.discourse-cdn.com/v4/letter/r/f19dbf/32.png) [@rmo518](https://forum.kirupa.com/u/rmo518)\
**Post date:** [April 16, 2006, 11:57pm UTC](https://forum.kirupa.com/t/3d-polar-revolution/185736/15 "2006-04-16T23:57:16Z")

</div>

Yeah, great work freeskier.

---

<div class="post-metadata">

**Author:** ![bombsledder](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@bombsledder](https://forum.kirupa.com/u/bombsledder)\
**Post date:** [April 17, 2006, 10:21am UTC](https://forum.kirupa.com/t/3d-polar-revolution/185736/16 "2006-04-17T10:21:57Z")

</div>

🙂 i like it

---

<div class="post-metadata">

**Author:** ![Soulberry](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@Soulberry](https://forum.kirupa.com/u/Soulberry)\
**Post date:** [April 17, 2006, 5:09pm UTC](https://forum.kirupa.com/t/3d-polar-revolution/185736/17 "2006-04-17T17:09:51Z")

</div>

Impressive…educative. Thanks for sharing with all of us.

---

<div class="post-metadata">

**Author:** ![Eberth](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/eberth/32/41_2.png) [@Eberth](https://forum.kirupa.com/u/Eberth)\
**Post date:** [April 20, 2006, 1:15am UTC](https://forum.kirupa.com/t/3d-polar-revolution/185736/18 "2006-04-20T01:15:48Z")

</div>

> [@freeskier89](#):
>
> Thanks guys! Here is another little add on. I am thinking that a 3d Fractal Tree is in order in the near future :D.

wow, that’s awesome, any chance we can have the source for that?:azn:

---

<div class="post-metadata">

**Author:** ![freeskier89](https://avatars.discourse-cdn.com/v4/letter/f/f475e1/32.png) [@freeskier89](https://forum.kirupa.com/u/freeskier89)\
**Post date:** [April 20, 2006, 2:07am UTC](https://forum.kirupa.com/t/3d-polar-revolution/185736/19 "2006-04-20T02:07:14Z")

</div>

> [@Eberth](#):
>
> wow, that’s awesome, any chance we can have the source for that?:azn:

Sure thing! Sorry about not posting earlier. I will edit my post in a few minutes with the source. Thanks btw 😃

---

<div class="post-metadata">

**Author:** ![anon1712571](https://avatars.discourse-cdn.com/v4/letter/a/9dc877/32.png) [@anon1712571](https://forum.kirupa.com/u/anon1712571)\
**Post date:** [April 20, 2006, 5:28am UTC](https://forum.kirupa.com/t/3d-polar-revolution/185736/20 "2006-04-20T05:28:17Z")

</div>

hey freeskier! Man that second effect is great!- that is exactly the kinda thing that would work for my glowy ribbons on the intro dont ya think? :P!

[Next page](https://forum.kirupa.com/t/3d-polar-revolution/185736.md?page=2)
