Math, help me.
A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Math, help me.

  1. #1
    Ok I have a circle.

    Origin 0,0.

    The Radius is dynamic, we'll call it X length.

    We need to find a dynamic number of points on this circle. All equidistant from each other. We'll call this number Y.

    Is there a formula to find the choordinates of each of the dynamic points?

  2. #2
    Senior Member
    Join Date
    Jan 2001
    Location
    HK | Toronto
    Posts
    989
    make 2 MC, the moving point and the circular centre (instance: a)

    put the following code to the moving point for circular motion.

    Code:
    onClipEvent(enterFrame) {
    	this._x=a._x+Math.cos(speed)*radius;
    	this._y=a._x+Math.sin(speed)*radius;
    	speed+=0.1;
    	radius=100;
    	}
    :o) Cheers
    Mkit

  3. #3
    Not what I was looking for, but works perfectly, thanks.

  4. #4
    Senior Member
    Join Date
    Jan 2001
    Location
    HK | Toronto
    Posts
    989
    Oh actually you can use those 2 equations to calculate the number of points, maybe store in the array.

    Code:
    storex = new Array();
    storey = new Array();
    radius=100;
    for (i=0;i<10;i++) {
    speed = random(360);
    storex[i]=a._x+Math.cos(speed)*radius;
    storey[i]=a._x+Math.sin(speed)*radius;
    trace(storex[i]+","+storey[i]);
    }
    you can add more REGULATIONs to either ground the value/ trancate the value / round the value.

    Cheers
    MKit

  5. #5
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,361
    watch those [i]'s MKit

    Heres a way to get points based on a distance value representing the distance in px you want those points to be away from each other (along the arc of the circle that is, not relatively in coordinate space)

    Code:
    twoPI = Math.PI*2 // just variable for 2 pi
    distance = 25 // distance between points on circle
    circ = twoPI*radius // radius is your dynamic "X length"
    numOfPoints = circ/distance
    angleMod = twoPI/numOfPoints
    points = [] // points stored in this array:
    for (angle = 0; angle <= twoPI-angleMod; angle += angleMod){
    	points[points.length] = [Math.cos(angle)*radius,Math.sin(angle)*radius]
    }
    points[index][0] = x value, and points[index][1] = y value

    [Edited by senocular on 07-10-2002 at 05:00 AM]

  6. #6
    Senior Member
    Join Date
    Jan 2001
    Location
    HK | Toronto
    Posts
    989
    Oh thanks senocular

    Originally posted by MKit
    Oh actually you can use those 2 equations to calculate the number of points, maybe store in the array.

    Code:
    storex = new Array();
    storey = new Array();
    radius=100;
    for (w=0;w<10;w++) {
    speed = random(360);
    storex[w]=a._x+Math.cos(speed)*radius;
    storey[w]=a._x+Math.sin(speed)*radius;
    trace(storex[w]+","+storey[w]);
    }
    you can add more REGULATIONs to either ground the value/ trancate the value / round the value.

    Cheers
    MKit

  7. #7
    http://www.geocities.com/imaretard_2002/tobesent.swf

    Watch out, I haven't compressed the images yet, though.

    Didn't expect that did you?

    How? Simple I stopped ._y movement, and made that value a temp variable called "Objdepth".. And accordingly change width height and alpha.

    Neat?

  8. #8
    Senior Member
    Join Date
    Jan 2001
    Location
    HK | Toronto
    Posts
    989
    hey steve, few months ago, I made the same thing too:

    http://member.hkbn.net/~f-mkit/kit/navigation.swf

    hehe~
    MKit

  9. #9
    yours wouldn't fully load for some reason, odd.

  10. #10
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,361
    I couldnt get either.. then again Im out in the boonies running about a 14.4 :-\

    I'll just sit here and pretend like I saw them and that I was impressed

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

Poll by Flashkit.com