For a particular purpose, I want to define a cylinder in 3D space and go through a list of given 3D points and tell if the point is inside or outside the cylinder volume. I can define the cylinder by specifying 2 points along the axis, and the radius of the cylinder.
A (x1, y1, z1 )
B (x2, y2, z2 )
and radius = R
right now what I'm doing is that I find the vector AB, connecting A and B by
AB = A - B
then calculate the shortest distance from each point to the vector AB, if the distance is less than R, the point is inside.
The problem with this method is that it only works if either A or B is the origin.
for example, If I try to find the points inside the cylinder connecting
p1 ( 100,10,20)
p2 ( 100,-10,20)
we get the points inside the cylinder ( 0,20,0) [ which is actually the cylinder formed by ( 0,0,0) and (0,20,0) ]
certainly, I'm missing something, can anyone point it out?
N.B: For some complicated reason, I can't use an auxiliary coordinate system or shift the origin. What I'm looking for is some pure mathematical expression ( if it exists ), which can take the particulars of the cylinder and the required point and give if it is inside or outside.
similar to Empty2
's answer on this question
similar to Empty2's answer on this https://math.stackexchange.com/questions/1472049/check-if-a-point-is-inside-a-rectangular-shaped-area-3d
– brownser Jan 22 '20 at 13:56