Register to reply

Determining if a given point is inside a right circular cylinder

by willworkforfood
Tags: circular, cylinder, determining, inside, point
Share this thread:
willworkforfood
#1
Nov23-07, 04:49 PM
P: 55
Defining the right circular cylinder, I have a vector formed between the centers of each 'cap' and a radius.

I need to determine if a given point (x,y,z) is inside the confines of this cylinder. And and all help is appreciated.
Phys.Org News Partner Mathematics news on Phys.org
'Moral victories' might spare you from losing again
Fair cake cutting gets its own algorithm
Effort to model Facebook yields key to famous math problem (and a prize)
CRGreathouse
#2
Nov23-07, 04:54 PM
Sci Advisor
HW Helper
P: 3,684
If it's aligned with the axes, this is easy. Say the circular face is on the x and y axes with the height on the z axis. Check the two-dimensional distance from the center of the cylinder to (x, y). If it's greater than the radius, it's outside; if less, continue. (If equal then continue, but note that if the second test passes it's actually on the border rather than being inside.) For the second, compare the bottom and top z-coordinates of the cylinder to z. If z is between the two it's inside; if equal to one of the two it's on the boundary; if outside the two it's outside.
willworkforfood
#3
Nov23-07, 04:55 PM
P: 55
Quote Quote by CRGreathouse View Post
If it's aligned with the axes, this is easy. Say the circular face is on the x and y axes with the height on the z axis. Check the two-dimensional distance from the center of the cylinder to (x, y). If it's greater than the radius, it's outside; if less, continue. (If equal then continue, but note that if the second test passes it's actually on the border rather than being inside.) For the second, compare the bottom and top z-coordinates of the cylinder to z. If z is between the two it's inside; if equal to one of the two it's on the boundary; if outside the two it's outside.
It is not defined on the axes :(

ice109
#4
Nov23-07, 06:19 PM
P: 1,705
Determining if a given point is inside a right circular cylinder

write the equation that defines the cylinder as an equality/inequality, plug in point and see if satisfies it.
CRGreathouse
#5
Nov23-07, 06:37 PM
Sci Advisor
HW Helper
P: 3,684
Quote Quote by willworkforfood View Post
It is not defined on the axes :(
Then I'd have to know how it's defined to answer that. If you have two systems of axes, you need to convert between them; if you have a parametric equation to define the cylinder, just check if it holds as an inequality.
dodo
#6
Nov24-07, 02:26 AM
P: 688
If the points at the centers of the caps are (ax,ay,az) and (bx,by,bz), you can write a parametric equation for the center line as x(t) = ax + t (bx-ax), y(t) = ay + t (by-ay), z(t) = az + t (bz-az), where t=0 or 1 will give you back the cap points.

The distance from a given point (px,py,pz) to any point in the line is given by the function d(t) = sqrt ( (x(t)-px)^2 + (y(t)-py)^2 + (z(t)-pz)^2 ). The closest point on the line (the proyection of your point onto the line) is found by minimizing d, that is, by setting d'(t) = 0 and solving for t. (You could do it by hand, using a math package, or using www.quickmath.com, menus Calculus/Differentiate and Equations/Solve).

Now, with the obtained t_min value, you can: (a) determine if t_min is <0 or >1 (or <=, >= to exclude the border), which would mean the given point was below one cap or above the other; and (b) calculate d(t_min), the distance from the line to your point, that will tell you if the point is farther than the cylinder's radius.

Edit:
Here, I was bored. (C source only.)
Attached Files
File Type: zip cylinder.zip (1.0 KB, 63 views)


Register to reply

Related Discussions
Electric Field inside a cylinder Introductory Physics Homework 10
Determining the coefficient of friction? (example inside) Introductory Physics Homework 1
HELP: contact area of Cylinder inside a larger Cylinder? General Math 6
Spinning around a cylinder with a person inside Introductory Physics Homework 5
B inside a cylinder of radius R Introductory Physics Homework 4