A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: 3B box trigonometry question ... experts?

Threaded View

  1. #1
    Bob (the singing sock)
    Join Date
    Aug 2000
    Location
    Århus, Denmark
    Posts
    472

    3B box trigonometry question ... experts?

    Hey

    I just checked out an excellent 3D tut here
    http://www.codylindley.com/Tutorials/trigonometry/

    I'm trying to point out the 8 x and y postitions in a box ...
    Perspective depth is not important in my case.
    I do need to incorporate a viewing angle (see attached trig.gif)

    any help out there?

    Kind Regards
    Poden

    ******** AS *********
    Code:
    // you'll need to make a linked clip named 'dot'
    function attBox(){
     var distance = 200;  // perspective
     var width = 150;  // box width
     var height= 200;  // box height
     var depth = 50;   // box depth
     // it takes 8 (x,y,x points) to make a box
     arrX = [width,width,width,width,0,0,0,0]  // xpos
     arrY = [height,height,0,0,height,height,0,0] // ypos
     arrZ = [depth,0,depth,0,depth,0,depth,0]  // zpos
     for(var i=0;i<arrX.length;i++){     // loop
      _root.attachMovie("dot",["dot"+i],i) // attaching mc 'dot'
      _mc = _root["dot"+i]     // variable mc name
      var x = arrX[i];
      var y = arrY[i];
      var z = arrZ[i];
      var perspective_ratio = distance/(distance+z)
      var perspective_x = x * perspective_ratio;
      var perspective_y = y * perspective_ratio;
      _mc._x = perspective_x;
      _mc._y = perspective_y;
     }
    }
    attBox()
    ******** AS *********
    Attached Images Attached Images
    Last edited by podenphant; 06-23-2005 at 05:29 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center