Generally, this type of problem belongs to “parallel problems” where multi-thread programing aproach can be applied to it. But code that solves this problem for 1 item (code inside loop) is extremly fast so implementing parallel programing solution will not improve speed for few 100.000s of items. If there is far more items (100s milions of points) then parallel-code could perform faster. Or if code inside the loop is heavy-one and takes longer time to execute (lets say 1 sec per 1 item) than even for low number of items (like few 100s) multi-thread code can execute faster.
Anyway here is code that implemets multi-threading - for loop is replaced with Parallel.For method so you can give it a try:
public static bool[] IsPointInsideCylinder02(Cylinder cylinder, Point3d[] points, double tolerance)
{
bool[] pointStatus = new bool[points.Length];
//pointStatus[i] = true => points[i] is inside of cylinder
Vector3d N = cylinder.Axis;
N.Unitize(); // N should be already unit size vector, but for any case...
Point3d C1 = cylinder.Center;
//we find base of cylinder = circle
Circle baseCircle = cylinder.CircleAt(cylinder.Height1);
double radiusWithTolerance = baseCircle.Radius + tolerance;
double SquareRadiusWithTolerance = radiusWithTolerance * radiusWithTolerance;
double t_C1 = 0;
double t_C2 = cylinder.TotalHeight;
t_C1 = t_C1 - tolerance;
t_C2 = t_C2 + tolerance;
Parallel.For(0, points.Length, i=>
{
double t = N.X * (points[i].X - C1.X) + N.Y * (points[i].Y - C1.Y) + N.Z * (points[i].Z - C1.Z);
double TX = C1.X + t * N.X;
double TY = C1.Y + t * N.Y;
double TZ = C1.Z + t * N.Z;
var SquareDistancePT = (points[i].X - TX) * (points[i].X - TX) +
(points[i].Y - TY) * (points[i].Y - TY) +
(points[i].Z - TZ) * (points[i].Z - TZ);
if (t < t_C1 || t > t_C2 || SquareDistancePT > SquareRadiusWithTolerance)
{
pointStatus[i] = false; //point not inside cylinder
}
else
{
pointStatus[i] = true;
}
} );
//
return pointStatus;
}