# Determining if a given point is inside a right circular cylinder

• willworkforfood
In summary, determining if a given point is inside a right circular cylinder requires checking its distance from the center of the cylinder to the point in 2D, and comparing the z-coordinate of the point to the bottom and top z-coordinates of the cylinder. If the point satisfies these criteria, it is inside the cylinder. If not, its distance from the center line of the cylinder must be checked using a parametric equation and minimizing the distance function.
willworkforfood
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.

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.

CRGreathouse said:
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 :(

write the equation that defines the cylinder as an equality/inequality, plug in point and see if satisfies it.

willworkforfood said:
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.

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.)

#### Attachments

• cylinder.zip
1 KB · Views: 574
Last edited:

## 1. How do you determine if a given point is inside a right circular cylinder?

To determine if a given point is inside a right circular cylinder, you can use the distance formula to calculate the distance between the given point and the center of the circular base of the cylinder. If this distance is less than the radius of the base, then the point is inside the cylinder.

## 2. Can a point be inside a right circular cylinder if it lies on the surface?

No, a point that lies on the surface of a right circular cylinder is considered to be outside the cylinder.

## 3. What information do you need to determine if a point is inside a right circular cylinder?

You will need the coordinates of the given point, the coordinates of the center of the circular base of the cylinder, and the radius of the base.

## 4. Can a point be inside a right circular cylinder if it is outside the height of the cylinder?

No, a point must be within the height of the cylinder in order to be considered inside it.

## 5. Is it possible for a point to be inside a right circular cylinder if it is not within the radius of the base?

No, a point must be within the radius of the base in order to be inside a right circular cylinder.

• Mechanical Engineering
Replies
16
Views
939
• Introductory Physics Homework Help
Replies
22
Views
1K
• General Math
Replies
1
Views
617
• Introductory Physics Homework Help
Replies
36
Views
586
• General Math
Replies
6
Views
2K
• Classical Physics
Replies
3
Views
299
• Mechanical Engineering
Replies
1
Views
1K
• Introductory Physics Homework Help
Replies
21
Views
2K
• Introductory Physics Homework Help
Replies
39
Views
2K
• Mechanical Engineering
Replies
7
Views
2K