[PHP] gd project question

2002-05-31 Thread Michael Geier

I have the following issue:

I am making a gas guage based on a percentage.
ie.  
- a 180 degree arc is created
- the range will be 0 to n (undetermined ammount)
- there will be x number of entries
- the needle will pount to a a percentage 
  for (int)floor((x / n) * 100)

The issue is, I have the starting pt for the needle (imagefilledarc 
needs the center of the 'circle' as the starting pt, which is where 
the needle will start too), but how would I get the x|y coordinates 
for the end of the needle based on a perentage of a half-circle 
(180 degree arc)?

Appreciate any clues or ideas.

---
Michael Geier


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] gd project question

2002-05-31 Thread Darren Gamble

Good day,

Wow, a high school math question.

You should use asin() and acos() of the angle to get the y and x
differentials, respectively.  Multiply the result by the size of the needle.

This assumes that your guage is oriented horizontally, and the needle sweeps
from right to left, pointing upwards.  Adjust the sign or switch the
functions around if your gauge is different.

Note that the functions operate in radians (2*pi radians == 360 degrees).


Darren Gamble
Planner, Regional Services
Shaw Cablesystems GP
630 - 3rd Avenue SW
Calgary, Alberta, Canada
T2P 4L4
(403) 781-4948


 -Original Message-
 From: Michael Geier [mailto:[EMAIL PROTECTED]]
 Sent: Friday, May 31, 2002 9:18 AM
 To: Php-General
 Subject: [PHP] gd project question
 
 
 I have the following issue:
 
   I am making a gas guage based on a percentage.
   ie.  
   - a 180 degree arc is created
   - the range will be 0 to n (undetermined ammount)
   - there will be x number of entries
   - the needle will pount to a a percentage 
 for (int)floor((x / n) * 100)
 
   The issue is, I have the starting pt for the needle 
 (imagefilledarc 
   needs the center of the 'circle' as the starting pt, 
 which is where 
   the needle will start too), but how would I get the x|y 
 coordinates 
   for the end of the needle based on a perentage of a half-circle 
   (180 degree arc)?
   
 Appreciate any clues or ideas.
 
 ---
 Michael Geier
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] gd project question

2002-05-31 Thread Michael Geier

Did I mention I hate math [grin]...
ok...so here we go so far...

I am passing a variable diameter of the arc ($d),
the total number of widgets possible ($n),
and the number of current widgets ($x)

so let's say $d = 100
 $n = 100
 $x = 50

 $perc = $x / $n (0.50 or 50 %)

 degree conversion = # * (180/M_PI)

 asin($perc) converted to degrees = 30
 acos($perc) converted to degrees = 60

my arc runs from 180 deg. to 360/0 degree, or left to right, pointing
upwards (upside down U).
i guess I am not getting my head around the numbers...is there anywhere on
the net that has a good thorough description about a process like this?

Thx.
mike

 -Original Message-
 From: Darren Gamble [mailto:[EMAIL PROTECTED]]
 Sent: Friday, May 31, 2002 11:40 AM
 To: 'Michael Geier'; Php-General
 Subject: RE: [PHP] gd project question


 Good day,

 Wow, a high school math question.

 You should use asin() and acos() of the angle to get the y and x
 differentials, respectively.  Multiply the result by the size of
 the needle.

 This assumes that your guage is oriented horizontally, and the
 needle sweeps
 from right to left, pointing upwards.  Adjust the sign or switch the
 functions around if your gauge is different.

 Note that the functions operate in radians (2*pi radians == 360 degrees).

 
 Darren Gamble
 Planner, Regional Services
 Shaw Cablesystems GP
 630 - 3rd Avenue SW
 Calgary, Alberta, Canada
 T2P 4L4
 (403) 781-4948


  -Original Message-
  From: Michael Geier [mailto:[EMAIL PROTECTED]]
  Sent: Friday, May 31, 2002 9:18 AM
  To: Php-General
  Subject: [PHP] gd project question
 
 
  I have the following issue:
 
  I am making a gas guage based on a percentage.
  ie.
  - a 180 degree arc is created
  - the range will be 0 to n (undetermined ammount)
  - there will be x number of entries
  - the needle will pount to a a percentage
for (int)floor((x / n) * 100)
 
  The issue is, I have the starting pt for the needle
  (imagefilledarc
  needs the center of the 'circle' as the starting pt,
  which is where
  the needle will start too), but how would I get the x|y
  coordinates
  for the end of the needle based on a perentage of a half-circle
  (180 degree arc)?
 
  Appreciate any clues or ideas.
 
  ---
  Michael Geier
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] gd project question

2002-05-31 Thread Miguel Cruz

On Fri, 31 May 2002, Michael Geier wrote:
 my arc runs from 180 deg. to 360/0 degree, or left to right, pointing
 upwards (upside down U).
 i guess I am not getting my head around the numbers...is there anywhere on
 the net that has a good thorough description about a process like this?

http://www.google.com/search?hl=enlr=q=%22trigonometry+tutorial%22

miguel


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php