Plot xy, coords to create a circle with centrepoint and radius

Click For Summary
SUMMARY

Darren is developing a PHP program to generate coordinates for circles to be imported into AutoCAD using the 3dpoly command. He successfully calculates X and Y coordinates using the formulas Offset + (r * cos(Angle * PI / 180)) and Offset + (r * sin(Angle * PI / 180)), respectively. However, he encounters a limitation when trying to create concentric circles with varying radii, as his current method uses a common start point instead of a common center point. The solution involves adjusting the logic to allow for a variable radius centered around a specific point.

PREREQUISITES
  • Understanding of trigonometric functions (sine and cosine)
  • Familiarity with PHP programming
  • Basic knowledge of AutoCAD commands, specifically 3dpoly
  • Concept of coordinate systems and plotting
NEXT STEPS
  • Research how to modify PHP code to calculate concentric circles using a common center point.
  • Learn about AutoCAD scripting and how to effectively use .scr files for automation.
  • Explore advanced trigonometric concepts for generating complex shapes in programming.
  • Investigate the use of layers in AutoCAD to manage multiple circles and shapes effectively.
USEFUL FOR

This discussion is beneficial for PHP developers, AutoCAD users, and anyone interested in generating geometric shapes programmatically for design and engineering applications.

Dazz
Messages
2
Reaction score
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
 
Physics news on Phys.org
Dazz said:
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
Allow r to be a variable, of course. In what you have given "Offset" is the x-coordinate of the center of the circle, r is the radius.
 
Hmm... i see. Well if it's not the maths (phew) then autocad layers must be screwing with me.

Thanks for your time.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 2 ·
Replies
2
Views
15K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 0 ·
Replies
0
Views
6K
  • · Replies 1 ·
Replies
1
Views
2K