40#ifndef LM_BUILDER_SHAPE_H_
41#define LM_BUILDER_SHAPE_H_
89 return (dx*dx + dy*dy + dz*dz);
118 bounding_box(
si_dist_t x1=0.0,
si_dist_t y1=0.0,
si_dist_t z1=0.0,
si_dist_t x2=0.0,
si_dist_t y2=0.0,
si_dist_t z2=0.0):
min(x1,y1,z1),
max(x2,y2,z2){}
132 return bounding_box(
::min(j.
min.
x,
min.x),
::min(j.
min.
y,
min.y),
::min(j.
min.
z,
min.z),
::max(j.
max.
x,
max.x),
::max(j.
max.
y,
max.y),
::max(j.
max.
z,
max.z));
142 double rx = (float)rand() / (float)RAND_MAX;
143 double ry = (float)rand() / (float)RAND_MAX;
144 double rz = (float)rand() / (float)RAND_MAX;
186 if ( fabs(v.
z) >= 1.0e-12 && fabs(-v.
x - v.
y) >= 1.0e-12)
254 matrix m( cos(theta)*cos(psi), cos(phi)*sin(psi) + sin(phi)*sin(theta)*cos(psi), sin(phi)*sin(psi) - cos(phi)*sin(theta)*cos(psi),
255 -cos(theta)*sin(psi), cos(phi)*cos(psi) - sin(phi)*sin(theta)*sin(psi), sin(phi)*cos(psi) + cos(phi)*sin(theta)*sin(psi),
256 sin(theta), -sin(phi)*cos(theta), cos(phi)*cos(theta));
263 return matrix(1.0, 0.0, 0.0,
uint32_t site_t
Definition Lattice.h:74
double si_dist_t
Definition Types.h:63
Abstract base class for all the shapes in Lattice Microbes simulation builder.
Definition Shape.h:305
vector up
Definition Shape.h:382
friend class LatticeBuilder
Definition Shape.h:385
virtual bool contains(Shape *query)=0
Determine if the shape contains the specified shape.
virtual ~Shape()
Destroy the Shape.
Definition Shape.cpp:157
virtual bounding_box getBoundingBox()
Get the bounding box.
Definition Shape.h:356
double integrateToCount(int count)
Definition Shape.cpp:221
vector at
Definition Shape.h:381
virtual double getVolume()=0
Get the total internal volume of the shape.
virtual point maxBounds(point p1, point p2) const
Definition Shape.h:374
matrix rotation
Definition Shape.h:383
ShapeType
Possible shape types that can be used in Lattice Microbes.
Definition Shape.h:310
@ CAPSULE_SHELL
Definition Shape.h:316
@ CUBOID
Definition Shape.h:315
@ TORUS
Definition Shape.h:321
@ INTERSECTION
Definition Shape.h:319
@ CONE
Definition Shape.h:323
@ CAPSULE
Definition Shape.h:314
@ UNIONSET
Definition Shape.h:324
@ HEMISPHERE
Definition Shape.h:312
@ CYLINDER
Definition Shape.h:313
@ UNION
Definition Shape.h:317
@ DIFFERENCE
Definition Shape.h:318
@ MESH
Definition Shape.h:320
@ ELLIPSE
Definition Shape.h:322
@ SPHERE
Definition Shape.h:311
bounding_box boundingBox
Definition Shape.h:377
virtual bool intersects(Shape *query)=0
Check if two shapes intersect.
virtual bool contains(point query)=0
Determine if the shape contains the specified point.
virtual point minBounds(point p1, point p2) const
Definition Shape.h:373
virtual ShapeType getShapeType()
Get the shape type.
Definition Shape.h:360
double integrateToPercentThreshold(double percent)
Definition Shape.cpp:200
site_t type
Definition Shape.h:378
ShapeType shapeType
Definition Shape.h:376
virtual site_t getType()
Get the site type associated with the shape.
Definition Shape.h:358
Shape(ShapeType shapeType, bounding_box boundingBox, site_t type, vector at=vector(0.0, 0.0, 1.0), vector up=vector(0.0, 1.0, 0.0))
Create a Shape.
Definition Shape.cpp:129
virtual bool boundingBoxesIntersect(Shape *query)
Checks if another shape's bounding box interstects with this shape's bounding box.
Definition Shape.cpp:161
virtual void discretizeTo(lm::rdme::Lattice *lattice)
Discretize the object to the specified lattice.
Definition Shape.cpp:169
Base class for lattice type objects.
Definition Lattice.h:132
Definition Capsule.cpp:47
struct lm::builder::bounding_box bounding_box
struct lm::builder::vector vector
struct lm::builder::point point
struct lm::builder::matrix matrix
Definition LatticeBuilder.h:60
Definition Capsule.cpp:46
The bounds for a shape represented as a rectangular box.
Definition Shape.h:110
point max
Definition Shape.h:125
point randomPointInside()
Retun a random point inside the bounding box.
Definition Shape.h:141
point min
Definition Shape.h:125
double volume()
Returns the bounding box volume.
Definition Shape.h:137
bounding_box(si_dist_t x1=0.0, si_dist_t y1=0.0, si_dist_t z1=0.0, si_dist_t x2=0.0, si_dist_t y2=0.0, si_dist_t z2=0.0)
Create a bounding box for coordinates.
Definition Shape.h:118
bounding_box(point min, point max)
Create a bounding box from points.
Definition Shape.h:122
bounding_box joinWith(bounding_box j)
Return a bounding box spanning the two bounding boxes.
Definition Shape.h:130
A matrix used for rotations.
Definition Shape.h:235
matrix(si_dist_t m11=0.0, si_dist_t m12=0.0, si_dist_t m13=0.0, si_dist_t m21=0.0, si_dist_t m22=0.0, si_dist_t m23=0.0, si_dist_t m31=0.0, si_dist_t m32=0.0, si_dist_t m33=0.0)
Create a matrix with the speficied elements.
Definition Shape.h:240
vector mult(const vector &r)
Multiply by a vector.
Definition Shape.cpp:113
si_dist_t m32
Definition Shape.h:297
si_dist_t m12
Definition Shape.h:291
si_dist_t m21
Definition Shape.h:293
matrix transpose()
Definition Shape.cpp:98
static matrix Identity()
Get an identity matrix.
Definition Shape.h:262
si_dist_t m31
Definition Shape.h:296
static matrix eulerMatrixFromAngles(si_dist_t phi, si_dist_t theta, si_dist_t psi)
Get a forward rotation matrix from angles.
Definition Shape.h:253
si_dist_t determinant()
Definition Shape.cpp:104
si_dist_t m13
Definition Shape.h:292
si_dist_t m23
Definition Shape.h:295
si_dist_t m22
Definition Shape.h:294
si_dist_t m11
Definition Shape.h:290
si_dist_t trace()
Definition Shape.cpp:108
si_dist_t m33
Definition Shape.h:298
Type to store a position in space.
Definition Shape.h:67
si_dist_t x
Definition Shape.h:73
si_dist_t distanceSquared(const point &p2)
Determine the distance squared between two points.
Definition Shape.h:84
si_dist_t y
Definition Shape.h:74
point(si_dist_t x=0.0, si_dist_t y=0.0, si_dist_t z=0.0)
Create a point.
Definition Shape.h:72
point plus(const vector &r)
Add the vector from the point.
Definition Shape.cpp:54
si_dist_t z
Definition Shape.h:75
point minus(const vector &r)
Subtract the vector from the point.
Definition Shape.cpp:50
si_dist_t distance(const point &p2)
Determine the distance to another point.
Definition Shape.h:105
point(const point &p2)
Create a point from another point.
Definition Shape.h:79
A vector which points in a direction.
Definition Shape.h:153
static vector findPerpendicularVector(vector v)
Definition Shape.h:185
vector unitize()
Get a unit vector pointing in the same direction as this vector.
Definition Shape.cpp:63
si_dist_t length()
Get the vector length.
Definition Shape.cpp:59
matrix mult(const vector &r)
Multiply with another vector (taking this vector to be a row vector) to form a matrix.
Definition Shape.cpp:86
point toPoint()
convert the vector to a point
Definition Shape.h:181
si_dist_t y
Definition Shape.h:227
si_dist_t z
Definition Shape.h:228
si_dist_t x
Definition Shape.h:226
vector(const point &p)
Construct a vector from a point.
Definition Shape.h:178
vector(const point &from, const point &to)
Construct a vector pointing from one point to another.
Definition Shape.h:166
vector(const vector &v)
Construct a vector from another vector.
Definition Shape.h:174
vector scale(const si_dist_t r)
Scale the vector by a constant.
Definition Shape.cpp:82
vector(si_dist_t x=0.0, si_dist_t y=0.0, si_dist_t z=0.0)
Create a vector.
Definition Shape.h:161
si_dist_t dot(const vector &r)
Compute the dot product between vectors.
Definition Shape.cpp:72
vector cross(const vector &r)
Compute the cross product between vectors.
Definition Shape.cpp:76