Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 27 July 2008 - 03:57 PM
Posted 27 July 2008 - 05:41 PM
Posted 27 July 2008 - 05:44 PM
Posted 27 July 2008 - 05:54 PM
Posted 27 July 2008 - 06:02 PM
Posted 27 July 2008 - 06:12 PM
Posted 27 July 2008 - 06:12 PM
f(x) = +-sqrt( r^2 - (x-x0)^2 ) - y0 and 0 where invalid
area = integral( 0, 1, clamp( f(x), 0, 1 ) )
Posted 27 July 2008 - 08:53 PM
Posted 27 July 2008 - 09:25 PM
Posted 27 July 2008 - 09:30 PM
Posted 28 July 2008 - 12:01 AM
Quote:
Original post by AngleWyrm
- Get area of circle
- Multiply by fraction of circle covered by chord ( = area of pie slice)
- Subtract area of isosceles triangle ( = area of circular segment)
- Add area of right triangle
Posted 28 July 2008 - 04:14 AM
Posted 28 July 2008 - 01:10 PM
Posted 28 July 2008 - 02:05 PM
Posted 28 July 2008 - 02:20 PM
Posted 29 July 2008 - 11:35 AM
int IntersectionLineSphere(vec *Q1, vec *Q2, vec A, vec B, vec P, float r)
{
vec pa = A - P;
vec ab = B - A;
float a = dot(ab,ab);
float b = dot(pa,ab);
float c = dot(pa,pa) - r*r;
float d = b/a;
float s = d*d-c/a;
if (s < 0.0f)
return 0; // sphere and line do not intersect
else
s = sqrtf(s);
float t1 = -d+s;
float t2 = -d-s;
*Q2 = A + ab * t1; // closer to B
*Q1 = A + ab * t2; // closer to A
int intersections = 0;
// intersection points within line segment?
if (t1 > 0.0f && t1 < 1.0f)
intersections++;
if (t2 > 0.0f && t2 < 1.0f)
intersections++;
// will be either 1 or 2
return intersections;
}
float SegmentOfCircle(vec Q1, vec Q2, vec P, float r)
{
vec s1 = Q1 - P;
vec s2 = Q2 - P;
float costheta = dot(s1,s2)/(length(s1)*length(s2));
return 0.5f*acosf(costheta)*r*r;
}
float AreaOfTriangle(vec A, vec B, vec C)
{
vec s1 = B - A;
vec s2 = C - A;
vec cr = cross(s1,s2);
return 0.5f * length(cr);
}
Posted 31 July 2008 - 07:08 PM
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.