50 assert(sideLengths.x > 0 && sideLengths.y > 0 && sideLengths.
z > 0);
66 Vec3 p = testPoint - _centerPoint;
70 for (
int i = 0; i < 3; i++)
72 if (p[i] < -_sideLengths[i] / 2)
74 bound.
point[i] = -_sideLengths[i] / 2;
76 else if (p[i] > _sideLengths[i] / 2)
78 bound.
point[i] = _sideLengths[i] / 2;
82 bound.
point[i] = p[i];
88 bound.
normal = (testPoint - bound.
point).GetUnitVector();
100 Vec3 p = testPoint - _centerPoint;
103 return (fabs(p.x) <= _sideLengths.x / 2) && (fabs(p.y) <= _sideLengths.y / 2) &&
104 (fabs(p.
z) <= _sideLengths.z / 2);
107 Vec3 GetRandomPositionInside(std::default_random_engine randomGen)
109 std::uniform_real_distribution<double> posX(-_sideLengths.x / 2, _sideLengths.x / 2);
110 std::uniform_real_distribution<double> posY(-_sideLengths.y / 2, _sideLengths.y / 2);
111 std::uniform_real_distribution<double> posZ(-_sideLengths.
z / 2, _sideLengths.
z / 2);
113 Vec3 randomPos =
Vec3(posX(randomGen), posY(randomGen), posZ(randomGen));
114 return _centerPoint + randomPos;
120 _centerPoint = center;
125 _sideLengths = sideLen;
An abstract class that defines the required properties of convex objects.
Boundary GetTangentPlane(Vec3 const testPoint)
Finds a separating plane between the prism and given point.
bool IsPointInside(Vec3 const testPoint)
Check whether a given point is inside or on the boundary of the prism.
RectPrism(Vec3 center, Vec3 sideLengths)
Constructor.
void SetCenterPoint(Vec3 center)
Sets the location of the center of the prism in global coordinates.
void SetSideLengths(Vec3 sideLen)
Sets the side lengths of the prism.
3D vector class with common vector operations.
double z
the three components of the vector
A struct defining the properties of a plane.
Vec3 point
A point on the plane.
Vec3 normal
A unit vector normal to the plane.