A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Trigonometry help

  1. #1
    Junior Member
    Join Date
    Nov 2008

    Unhappy Trigonometry help

    Help! I've never learn trigonometry!
    I have two circles and need to make tangent lines conecting both.
    This is probably a basiq question but I just cant find how!

  2. #2
    Senior Member ironmallet's Avatar
    Join Date
    Feb 2001

    Conveyor Belt Trigonometry


    // I only got one 'side' of the conveyor belt so far and it is flawed somehow
    // a large wheel close to a small one and it gets funky
    // interesting problem

    //a,b center of the first circle
    //c,d center of the second circle
    //x1,y1 'top' tangent point on the first circle
    //x2,y2 'top' tangent point on the second circle
    //g angle between segment ab_cd and ab_x1y1
    //g is also the angle between ab_cd and cd_x2y2
    //h is not shown in the diagram, it is the angle between ab_cd and horizon
    //dist=distance between the two centers

    dist = Math.sqrt((c*c-a*a)+(d*d-b*b));
    g = Math.acos((r1-r2)/dist);
    h = Math.atan((b-d)/(c-a));

    // 'top' of belt
    x1 =Number(a)+Number(Math.round(1000*r1*Math.cos(g-h))/1000);
    y1 =Number(b)+Number(Math.round(1000*r1*Math.sin(g-h))/1000);
    x2 = Number(c)+Number(Math.round(1000*r2*Math.cos(g-h))/1000);
    y2 = Number(d)+Number(Math.round(1000*r2*Math.sin(g-h))/1000);
    Last edited by ironmallet; 12-23-2008 at 02:13 AM. Reason: fla

  3. #3
    Junior Member
    Join Date
    Dec 2008
    Ah, this is some tasty math. I will do a quick review of my discreet and then post back with some formulas

  4. #4
    Junior Member
    Join Date
    Dec 2008
    you will need an if statement something like this

    if circle1.radius>circle2.radius
    elseif circle1.radius>circle2.radius
    else *(circle1.radius=circle2.radius)*{
    the code you currently have will fit here

    I will explain my math if you need help but it is pretty complicated so I will save you the confusion for now

    note:you must reverse circle 1 and 2 for the second if statement
    if circle1.radius>circle2.radius {
    offsetangle = Math.asin(circle1.radius/(dist+n))

    now the offsetangle is the angle, in radians, you must add to the top and subtract from the bottom of both circles in order to get the correct tangent.
    Although, I could be wrong, you might have to subtract from the top and add to the bottom.
    Last edited by nichaey; 01-03-2009 at 05:40 PM. Reason: Dang Dirty Apes

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