diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-10-22 15:56:48 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-10-22 15:56:48 -0400 |
commit | f020830fdb69968b46f24c48869635d28211963d (patch) | |
tree | a8927363e823fc4c94f24854cc3347ef3e818f0c /libdimension | |
parent | 7d46eba1e14596af1d745652de533f801cff0c65 (diff) | |
download | dimension-f020830fdb69968b46f24c48869635d28211963d.tar.xz |
Fix inside calculation for cones.
Diffstat (limited to 'libdimension')
-rw-r--r-- | libdimension/cylinder.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libdimension/cylinder.c b/libdimension/cylinder.c index 62c1476..1c08b7c 100644 --- a/libdimension/cylinder.c +++ b/libdimension/cylinder.c @@ -150,6 +150,9 @@ static bool dmnsn_cylinder_inside_fn(const dmnsn_object *cylinder, dmnsn_vector point) { point = dmnsn_transform_vector(cylinder->trans_inv, point); - return point.x*point.x + point.z*point.z < 1 - && point.y > -1.0 && point.y < 1.0; + dmnsn_cylinder_payload *payload = cylinder->ptr; + double r1 = payload->r1, r2 = payload->r2; + double r = (point.y*(r2 - r1) + r1 + r2)/2.0; + return point.x*point.x + point.z*point.z < r*r + && point.y > -1.0 && point.y < 1.0; } |