Forum How do I...?

HELP! Create a SVG wedge

next2heaven
I need help creating a wedge. I will know the radius, start rotation and end rotation. how can i create an arc/wedge?
mikeday
Have you tried using the arc command in a path?
next2heaven
Thanks.

The problem is that I only know the center point as well as the start and end rotation values. It looks like the arc command needs to know the points around the edge of the circle. Not sure of the formula to figure that out.
mikeday
If you know the centre point, the radius, and the start and end angles, you can find the start and end points of the arc like this:
start_x = centre_x + cos(start_angle)*radius
start_y = centre_y + sin(start_angle)*radius

end_x = centre_x + cos(end_angle)*radius
end_y = centre_y + sin(end_angle)*radius

Basic geometry, you just need to check a few things: what programming language are you using? Do the cos() and sin() functions expect degrees, or radians? Basic geometry. :)
next2heaven
Gotcha. My only problem now is that I'm trying to figure out how it all fits together. I'm doing the following:

function drawWedge($xx, $yy, $rad, $startRot, $endRot, $inColor, $outColor, $outSize){
	$startRot = $startRot;
	$endRot = $endRot;
	$startX = $xx + cos($startRot)*$rad;
	$startY = $yy + sin($startRot)*$rad;
	$endX = $xx + cos($endRot)*$rad;
	$endY = $yy + sin($endRot)*$rad;
	return '<path d="M'.$startX.','.$startY.' h'.$rad.' a'.$endX.','.$endY.' 0 1,0 '.$xx.','.$yy.' z" '.$inColor.' stroke="#'.$outColor.'" stroke-width="'.$outSize.'"; />'
}


The circle is skewed with how I've got it. Any ideas?
mikeday
Can you paste some examples of input values and the SVG path you are getting as output? (Also, why does drawWedge begin with "$startRot = $startRot; isn't that redundant?)
next2heaven
Sorry about that. I was taking out this:

$startRot = norm($startRot);

etc.

It was a function to times the value by a percent (the scale percent). Don't worry about that part. That part is fine for all my shapes. Just need help with the wedge.
mikeday
Okay, can you paste some actual values you are getting out?