Math challenge
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Math challenge
Equation for a circle (simplified to have center (0,0)) can be given by:
y^2 + x^2 = r^2
Thus:
y = sqrt( r^2 - x^2 )
Let's say we have a circle of radius 10 units:
y = sqrt( 100 - x^2 )
So if we plot points for($x=-10; $x<=10; $x+=0.1) we'd get a circle and we could create a function to get the y values for each value of x.
Problem I'm facing. I can make the circle BUT the points are plotted equidistantly on a horizontal line, not equidistantly as you travel around the perimiter of the circle. What I need to do is to ensure that all of the points around the edge of the circle are equally spaced.
http://www.iris.ac/~cac/gtest2.php (wrong spacing)
One way I can think of is to determine the appropriate X values to use before-hand.
Is anybody enough of a maths wizard to be able to determine a function that provides an appropriate sequence of numbers along the X axis that result in those dots in my example all being equally spaced out?
y^2 + x^2 = r^2
Thus:
y = sqrt( r^2 - x^2 )
Let's say we have a circle of radius 10 units:
y = sqrt( 100 - x^2 )
So if we plot points for($x=-10; $x<=10; $x+=0.1) we'd get a circle and we could create a function to get the y values for each value of x.
Problem I'm facing. I can make the circle BUT the points are plotted equidistantly on a horizontal line, not equidistantly as you travel around the perimiter of the circle. What I need to do is to ensure that all of the points around the edge of the circle are equally spaced.
http://www.iris.ac/~cac/gtest2.php (wrong spacing)
One way I can think of is to determine the appropriate X values to use before-hand.
Is anybody enough of a maths wizard to be able to determine a function that provides an appropriate sequence of numbers along the X axis that result in those dots in my example all being equally spaced out?
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Nah, to answer your question seriously I'm writing a graphing library in PHP with the goal of providing something similar to JPGraph (Roja has helped out/is helping out on the current version) except that it will NOT depend on GD or anything other than a vanilla PHP installation. It's all CSS based.onion2k wrote:Pfft. Nothing is more fun than mucking about with GD.d11wtq wrote:Because this is more funonion2k wrote:Why not generate an image?
Well, a few things are, but they're nothing to do with PHP.
The current version only did Bar Graphs... this one will do any number of things. This was for a pie chart. Yes yes I know the markup is huge but I have ideas on ways to bring that down in size... I just needed the basic maths worked out first
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
There are a number of DHTML drawing libraries. The Walter Zorn one is probably the oldest here. If you Google "javascript drawing library" you can find a bunch.
You should especially look at PlotKit which does all kinds of graphs using either Javascript or SVG. Very cool. It's built on Mochikit.
You should especially look at PlotKit which does all kinds of graphs using either Javascript or SVG. Very cool. It's built on Mochikit.
(#10850)
Haven't you considered to use canvas instead of html+css?d11wtq wrote: Nah, to answer your question seriously I'm writing a graphing library in PHP with the goal of providing something similar to JPGraph (Roja has helped out/is helping out on the current version) except that it will NOT depend on GD or anything other than a vanilla PHP installation. It's all CSS based.
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
