Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Finding the radius ?

Author
Message
HowDo
22
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 3rd Jan 2010 16:01
Hi All

How do I find out the radius for a circle.

I know the center x,y of the circle but the other end is an object which rotates around this center and moves in and out, giving me many x,y positions.

So how do I make this moving x,y give me the radius I need?

would it be take x2,y2 away from x,y?

Dark Physics makes any hot drink go cold.
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Jan 2010 16:21
No.

Assuming the point (x2, y2) is on the circumference of the circle then you just need the distance between the two points, i.e.



or equivalent expression.

You may need to decide whether you are working with integers or floats, of course.
HowDo
22
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 3rd Jan 2010 16:40
Cheers Green Gandalf ,work perfect, whats the name of the above calculation.

Dark Physics makes any hot drink go cold.
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Jan 2010 16:45 Edited at: 3rd Jan 2010 16:46
Length of the line joining two points, perhaps?

Or

Distance between two points?

Or

Euclidean distance between two points?
gbark
19
Years of Service
User Offline
Joined: 14th Oct 2005
Location: US - Virginia
Posted: 3rd Jan 2010 17:24 Edited at: 3rd Jan 2010 17:25
HowDo, it actually comes from the Pythagorean Theorem. In a right triangle: A^2 + B^2 = C^2

In a euclidean (x/y) coordinate system, such as what DBPro uses, you can effectively treat A and B as the X and Y distances between two points, which gives you a right triangle whose hypotenuse representing the distance "C". Using basic algebra to solve for C, and treating A as the distance between two X points and B as the distance between two Y points, you get C = sqrt((x1-x2)^2+(y1-y2)^2)


But I just call it the "distance equation".
Veron
18
Years of Service
User Offline
Joined: 22nd Nov 2006
Location:
Posted: 3rd Jan 2010 17:29
You can also use:

(x-a)^2+(y-b)^2 = r^2

Where a/b is the centre of the circle, and r is the radius. You can rearrange it to find either r or a/b.

Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 4th Jan 2010 16:43 Edited at: 4th Jan 2010 16:45
Quote: "HowDo, it actually comes from the Pythagorean Theorem. In a right triangle: A^2 + B^2 = C^2"


Well, I guess it has multiple names.
Actually, in linear algebra the length of a vector is defined as d = sqrt( <a,a> ) (<a,a> is a notation for a dot product).

This definition is valid in all coordinate systems, as it's only using vectors. It's just that in an Euclidean coordinate system this dot product is written as:
<a,b> = ax*bx + ay*by + az*bz
Combined with:
ab = b - a (Chasles-Mobius)
<ab,ab> = <b-a,b-a> = (bx-ax)^2 + (by-ay)^2 + (bz - az)^2

Another way is of course drawing it and using a right triangle.

So basically you can call it what you want. Pythagoras generally refers to the special case of the cosine formula for triangles:
a^2 = b^2 + c^2 - b*c*cos(alpha) where alpha is the opposite angle of side a.
When the triangle is right, this formula changes to
a^2 = b^2 + c^2 as alpha = 90°

Cheers!
Sven B

[edit] I have no idea why I'm telling this...

Login to post a reply

Server time is: 2025-05-29 05:58:21
Your offset time is: 2025-05-29 05:58:21