public Bounds GetBoundFromPoints(Vector3d[] points, out Vector3d max, out Vector3d min) { var center = points.Aggregate(Vector3d.zero, (current, t) => current + t) / 8; min = new Vector3d(double.MaxValue, double.MaxValue, double.MaxValue); max = new Vector3d(double.MinValue, double.MinValue, double.MinValue); for (int i = 0; i < points.Length; i++) { var p = points[i]; p = RotationMatrix.MultiplyVector(p); if (p.x < min.x) { min.x = p.x; } if (p.y < min.y) { min.y = p.y; } if (p.z < min.z) { min.z = p.z; } if (p.x > max.x) { max.x = p.x; } if (p.y > max.y) { max.y = p.y; } if (p.z > max.z) { max.z = p.z; } } var size = max - min; return(new Bounds(center, size)); }
public float GetBoxSizeAlongNormalizedDirection(Vector3 direction) { Vector3 transformedBoxSizeVector = RotationMatrix.MultiplyVector(_boxSize); return(direction.GetAbsDot(transformedBoxSizeVector)); }