Sign in to follow this  
Followers 0
Ham123

"geometry" autoit help?

5 posts in this topic

So basically this is it, im trying to program a simple game.

There is a graph with a circle located on it. Its center is at the origin, and its radius is any number you want. lets call it x.

There is a radius drawn from the center to any random point on the circle. for this example, lets say the radius is 8, and the intersection is at

(6, 2*sqrt7)

The second intersection is at (0,8)

How would one find out the degrees (or distance) along the circle from the first point, to the second?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You can use trigonemetric ratios to find the degrees. Cos(X) = 6/8. X is your degrees.

Edited by dantay9

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

Well. If you want a more long winded method than dantays, try this out.

We have a triangle where

Point a = 0,0

Point b = 6, sqrt (11)

Point c = 0, 8

from there we know the sides

c = sqrt (6^2 + sqrt (11) ^ 2) = sqrt (36 + 11) = sqrt (47)

b = 8

a = sqrt (6^2 + (8 - sqrt (11)) ^ 2) = sqrt (36 + (8 - sqrt (11)) ^ 2)

We know know all the sides of a triangle. Use my very nice triangle calculator (or the cosine rule). you should get

A = 61.07°

B = 66.91°

C = 52.02°

If you want the maths...

Cosine rule:

cos A = (b^2 + c^2 - a^2) / 2bc

A = acos( (( 8 ^ 2) ^ 2 + 47 - (36 + (8 - sqrt (11) ^ 2))) / 2 * 8 * sqrt (47))

which gives an error :) I give up. but you get the idea! when I am in the mood I'll try to find out where I went wrong.

MDiesel

Share this post


Link to post
Share on other sites

Well. If you want a more long winded method than dantays, try this out.

We have a triangle where

Point a = 0,0

Point b = 6, sqrt (11)

Point c = 0, 8

from there we know the sides

c = sqrt (6^2 + sqrt (11) ^ 2) = sqrt (36 + 11) = sqrt (47)

b = 8

a = sqrt (6^2 + (8 - sqrt (11)) ^ 2) = sqrt (36 + (8 - sqrt (11)) ^ 2)

We know know all the sides of a triangle. Use my very nice triangle calculator (or the cosine rule). you should get

A = 61.07°

B = 66.91°

C = 52.02°

If you want the maths...

Cosine rule:

cos A = (b^2 + c^2 - a^2) / 2bc

A = acos( (( 8 ^ 2) ^ 2 + 47 - (36 + (8 - sqrt (11) ^ 2))) / 2 * 8 * sqrt (47))

which gives an error :party: I give up. but you get the idea! when I am in the mood I'll try to find out where I went wrong.

MDiesel

thank you for this, however, i think you guys misunderstood my question. i mean the distance along the circle from point to point.

but its all good, i figured it out, going to use atan for it :)

Share this post


Link to post
Share on other sites

So basically this is it, im trying to program a simple game.

There is a graph with a circle located on it. Its center is at the origin, and its radius is any number you want. lets call it x.

There is a radius drawn from the center to any random point on the circle. for this example, lets say the radius is 8, and the intersection is at

(6, 2*sqrt7)

The second intersection is at (0,8)

How would one find out the degrees (or distance) along the circle from the first point, to the second?

This appears to work.

;
$x1 = 0; First x position
$x2 = 6; Second x position
$Radius = 8

#cs
    $ang1 =  ACos($x1/$Radius)
    ConsoleWrite($ang1*180/(4 * ATan(1)) & @CRLF)
    $ang2 =  ACos($x2/$Radius)
    ConsoleWrite($ang2*180/(4 * ATan(1)) & @CRLF)
    
    $deg = abs($ang2 - $ang1)*180/(4 * ATan(1))
    
; eg. in degrees if angle difference was 90deg, $ratio would equal 90/360 i.e. 1/4 of the perimeter of the circle
    $ratio = abs($ang2 - $ang1)/(8 * ATan(1)) ; Note (4 * ATan(1)) = Pi
    $ArcLength = 8 * ATan(1) * $Radius * $ratio; 2*Pi*radius*Ratio
    
#ce
$deg = Abs(ACos($x2 / $Radius) - ACos($x1 / $Radius)) * 180 / (4 * ATan(1))
$ArcLength = 8 * ATan(1) * $Radius * Abs(ACos($x2 / $Radius) - ACos($x1 / $Radius)) / (8 * ATan(1))
MsgBox(0, "", "Degree difference = " & Round($deg, 4) & @CRLF & "Arc length = " & Round($ArcLength, 4))
;

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0