User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11

Thread: Math issue - How can I determine the distance from a point to the edge of a circle ?

  1. #1
    Clicker Fusion 2.5 MaciOS Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    TGeorgeMihai's Avatar
    Join Date
    Nov 2015
    Posts
    122
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Question Math issue - How can I determine the distance from a point to the edge of a circle ?

    How can I determine the linear distance from a point to the edge of a circle ?

    Please see the following image (I want the distance of the blue lines)
    distanceToCircle.png

    I have something that works, but uses an active that is moved every frame to the edge of the circle (fastloop for 180 angles) that opens another fastloop that moves another active pixel by pixel until it reaches the point.

    It kind of works, but I know it uses more resources then it should... And there should be a math formula for this.

    Here I've found some useful links:
    https://stackoverflow.com/questions/...r-from-tangent

    http://paulbourke.net/dome/fisheye
    Not needed right now, but I would really like to know if Angular fisheye (figures 2 and 3) could be calculated with Fusion events

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)

    Join Date
    Sep 2017
    Location
    Milano, Italy
    Posts
    130
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Supposed you have the Radius (R) of the circle and the Height (H) of the total figure, using the Angle (A) yuo signed here the Blu Line Lenght (Bl) is:
    Bl = H - R*Cos(A)

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)

    Join Date
    Sep 2017
    Location
    Milano, Italy
    Posts
    130
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Here with a little more time to work around it I made this little Example, I tested it just two/three times but it seems to work.
    The important thing here is where I put the hotspot for calculus, the circle is in top/middle, the line and active diamond in the center... so the calculus are based between this points.
    Change the orientation of the system is just a little bit of work but the idea is similar.

    FishEyeTest.mfa

    Also I used alterable values to separate the calculus passages, but it is possible to bind them togheter if you need it.

  4. #4
    Clicker Fusion 2.5 MaciOS Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    TGeorgeMihai's Avatar
    Join Date
    Nov 2015
    Posts
    122
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much, I will try it when I get home

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)

    Join Date
    Sep 2017
    Location
    Milano, Italy
    Posts
    130
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    If you want to see, this is the math used

    moddedMath.jpg

  6. #6
    Clicker Fusion 2.5 MaciOS Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    TGeorgeMihai's Avatar
    Join Date
    Nov 2015
    Posts
    122
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Really detailed information, I managed to implement it and works, but it seems that I was wrong in first place.

    I really need to use Angular fisheye , not Hemispherical
    http://paulbourke.net/dome/fisheye (figures 2 and 3)

    I would really appreciate if you could help me again with this, or at least with the formulas.
    I need to get X2,Y2 from X1,Y1
    distanceToCircle2.png

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)

    Join Date
    Sep 2017
    Location
    Milano, Italy
    Posts
    130
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Edited by me...

    I readed better your links and I have some questions (sorry but I have problem with english so I need to read several times to be sure to understand).

    Your goal is to know how long is the blue line or to know where is the X coordinate on the bottom depending on the angle? (or oter condition, objects position...)
    Because I think I misunderstood the problem reading the links you gave

  8. #8
    Clicker Fusion 2.5 MaciOS Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    TGeorgeMihai's Avatar
    Join Date
    Nov 2015
    Posts
    122
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    I want to know the formula for x2 y2 from that image.
    I know the values for x1 y1, height of the total figure, the center of circle and the radius.

    Basically I want to "roll" o line of actives alongside a circle.

  9. #9
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)

    Join Date
    Sep 2017
    Location
    Milano, Italy
    Posts
    130
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Here I am, in this days I was a little busy.

    I read the link on the angular fisheye and it is simply a linear correspondence between the X of the projected point and the Angle on the circle.
    So all we need to do is write a linear function to link X with the angle A like a straight line equation starting from the left edge of the frame linked to -90 degree, we call this S(0,-90), to the right edge at 90 degree called E(Width-1,90).

    The equation to find the angle A on the circle is:

    A - Sy = m*(X-Sx) with m=(Ey-Sy)/(Ex-Sy) so if we put the data into the formula and rearrange it we have

    A - 90 = (90 + 90)/(Width-1) * X => A = 180/(Width-1) * X - 90

    Now that we have the angle A to find the X2 and Y2 point on the circle we simple use Sin and Cos, C is the center point and R the radius

    X2 = Cx + R*Sin(A)
    Y2 = Cy + R*Cos(A)

    NOTE: differently from your image I put the -90 degree on the left and the 90 degree on the right because of the sign of the Sin function, using the original orientation you need to change the value in the S and E point and use a - sign instead of a + in the X2 calculation

    NOTE2: to work the circle need to be in the center of the Width Frame, it is possible to think at something different and it is not too difficult but at the moment I have no time, if you need this I can work on it but not now.

    Here is the Exemple file

    AngularFishEye.mfa

  10. #10
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)

    Join Date
    Sep 2017
    Location
    Milano, Italy
    Posts
    130
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Here I added a Frame in the last example with the possibility to change the Cx position of the circle by R-Click and drag the red circle.
    In this custom version the projection on the bottom plane is not equally linear for all the screen width, but have two different coefficient depending on the position on the left or on the right of Cx.
    To do this I split the linear equation in two, the first with S(0,-90)-E(Cx,0) and the second with S(Cx,0)-E(Width-1,90), now you can easily write the two functions as in the previus post.
    Then yuo need to use them in two separate event, the first in the event X<=Cx and the second in X>Cx (this is a "piecemeal function"), the Sin/Cos calculus for the point coordinate is the same.

    Now you can see the different behavior on the left and right part of the circle depending on wich one is closer to one of the frame borders, on the side closer to the border the point projected on the circunference move faster than the one on the other side.

    AngularFishEye.mfa

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Replies: 0
    Last Post: 3rd July 2015, 11:26 PM
  2. Possible Physics Floating Point or Scope Issue?
    By rocketappliances in forum Fusion 2.5
    Replies: 7
    Last Post: 27th January 2015, 11:58 PM
  3. Clickteam Movement Controller to determine distance
    By ICEzW3RG in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 10th December 2013, 06:07 AM
  4. Distance along an angle? (math)
    By alspal in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 7th November 2011, 07:46 AM
  5. Determine distance from objects ("A" to "B")
    By Oreo in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 4th April 2010, 02:47 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
  •