- #1
Dazz
- 2
- 0
Hey all,
I posted this in a thread with similar discussions but thought to make a new one. Skip to the last two sections if you're in a rush :)
About me
------------
I did maths in high school and stats in university but I can't work some (probably elementary) sin / cos / tan stuff out. I was hoping someone could assist me? Unfortunately, after years of circular neglect, my maths has fallen by the way side on this.
Setting the scene
--------------------
I am looking to write a PHP program to output coords for a circle. I intend to import these into Autocad via .scr file, initially to create the circle using the Atocad 3dpoly command, but later to modify the code to create things like 3d parallel spirals... and other interesting things Autocad doesn't like.
Current usage
----------------
The php code I have works somewhat, but not exactly how I want it. Converting the code into english... I can currently get an X coord by using the following logic (each term is described under the logic).
Offset + (r * cos(Angle * PI / 180))
Offset: A number to move my diagram into positive values in autocad
r: the radius of the circle
Angle: The angle, a value between 0 and 359
PI: the magic circle number (3.14ish)
I can also get the Y coord a similar way using sin
I use this formula, passing an angle of 0 through to 359, to create coords for a circle.
The problem
-------------
The above works fine and I can draw a circle by using the formula, increasing the angle and plotting the point.
What this doesn't do is allow me to shorten the radius for a second circle inside the first with a constant displacement. I believe it's because the technique above creates a circle using a common start point rather than a common centre point.
My Question
-------------
What logic should I use to plot a circle using a centre point so that the radius can be varied?
Thanks in advance for any help.
Darren
I posted this in a thread with similar discussions but thought to make a new one. Skip to the last two sections if you're in a rush :)
About me
------------
I did maths in high school and stats in university but I can't work some (probably elementary) sin / cos / tan stuff out. I was hoping someone could assist me? Unfortunately, after years of circular neglect, my maths has fallen by the way side on this.
Setting the scene
--------------------
I am looking to write a PHP program to output coords for a circle. I intend to import these into Autocad via .scr file, initially to create the circle using the Atocad 3dpoly command, but later to modify the code to create things like 3d parallel spirals... and other interesting things Autocad doesn't like.
Current usage
----------------
The php code I have works somewhat, but not exactly how I want it. Converting the code into english... I can currently get an X coord by using the following logic (each term is described under the logic).
Offset + (r * cos(Angle * PI / 180))
Offset: A number to move my diagram into positive values in autocad
r: the radius of the circle
Angle: The angle, a value between 0 and 359
PI: the magic circle number (3.14ish)
I can also get the Y coord a similar way using sin
I use this formula, passing an angle of 0 through to 359, to create coords for a circle.
The problem
-------------
The above works fine and I can draw a circle by using the formula, increasing the angle and plotting the point.
What this doesn't do is allow me to shorten the radius for a second circle inside the first with a constant displacement. I believe it's because the technique above creates a circle using a common start point rather than a common centre point.
My Question
-------------
What logic should I use to plot a circle using a centre point so that the radius can be varied?
Thanks in advance for any help.
Darren