Random generators for lots of different geometric types, intended for use in tests. 10 meters is
(arbitrarily) used as the basic scale for generated values, so for example the point3d
generator
will generate points where each coordinate value is in the range -10 meters to +10 meters.
This is only to have values be roughly the same scale (which helps to ensure that random tests
actually do trigger things like intersections between objects) but do not rely on geometry being
strictly contained within the -10...+10 meter bounds. For example, the circle2d
generator will
create circles where the center point is within those bounds, and the radius is up to 10 meters,
meaning that the circle may well extend to larger or smaller coordinate values.
Most of the higher-level generators in this module are built pretty directly from lower-level
generators - for example the axis3d
generator is implemented as:
axis3d : Generator (Axis3d Meters coordinates)
axis3d =
Random.map2 Axis3d.through point3d direction3d
parameterValue : Random.Generator Basics.Float
Generate a parameter value between 0 and 1.
scale : Random.Generator Basics.Float
Generate a value between -10 and +10 to use for scaling geometry. (Note that this includes 0.)
length : Random.Generator Length
Generate a random length between -10 meters and +10 meters.
positiveLength : Random.Generator Length
Generate a random length between 0 and 10 meters.
angle : Random.Generator Angle
Generate a random angle between -360 and +360 degrees.
unitlessQuantity : Random.Generator (Quantity Basics.Float Quantity.Unitless)
Generate a random unitless quantity between -10 and +10.
unitlessInterval : Random.Generator (Quantity.Interval.Interval Basics.Float Quantity.Unitless)
Generate a random unitless interval with endpoints between -10 and +10.
direction2d : Random.Generator (Direction2d coordinates)
Generate a random 2D direction.
direction3d : Random.Generator (Direction3d coordinates)
Generate a random 3D direction.
vector2d : Random.Generator (Vector2d Length.Meters coordinates)
Generate a random 2D vector with components in the range -10 to +10 meters.
vector3d : Random.Generator (Vector3d Length.Meters coordinates)
Generate a random 3D vector with components in the range -10 to +10 meters.
point2d : Random.Generator (Point2d Length.Meters coordinates)
Generate a random 2D point with components in the range -10 to +10 meters.
point3d : Random.Generator (Point3d Length.Meters coordinates)
Generate a random 3D point with components in the range -10 to +10 meters.
boundingBox2d : Random.Generator (BoundingBox2d Length.Meters coordinates)
boundingBox3d : Random.Generator (BoundingBox3d Length.Meters coordinates)
vectorBoundingBox2d : Random.Generator (VectorBoundingBox2d Length.Meters coordinates)
vectorBoundingBox3d : Random.Generator (VectorBoundingBox3d Length.Meters coordinates)
axis2d : Random.Generator (Axis2d Length.Meters coordinates)
axis3d : Random.Generator (Axis3d Length.Meters coordinates)
plane3d : Random.Generator (Plane3d Length.Meters coordinates)
sketchPlane3d : Random.Generator (SketchPlane3d Length.Meters coordinates { defines : sketchCoordinates })
frame2d : Random.Generator (Frame2d Length.Meters coordinates { defines : localCoordinates })
frame3d : Random.Generator (Frame3d Length.Meters coordinates { defines : localCoordinates })
lineSegment2d : Random.Generator (LineSegment2d Length.Meters coordinates)
lineSegment3d : Random.Generator (LineSegment3d Length.Meters coordinates)
triangle2d : Random.Generator (Triangle2d Length.Meters coordinates)
triangle3d : Random.Generator (Triangle3d Length.Meters coordinates)
rectangle2d : Random.Generator (Rectangle2d Length.Meters coordinates)
rectangle3d : Random.Generator (Rectangle3d Length.Meters coordinates)
polygon2d : Random.Generator (Polygon2d Length.Meters coordinates)
The polygon2d
generator is a bit special. Since randomly generating vertices and then
connecting them would almost always result in useless self-intersecting polygons, this instead
generates polygons of a few different types that are non-self-intersecting by construction:
All the polygons will be roughly centered on the origin.
block3d : Random.Generator (Block3d Length.Meters coordinates)
arc2d : Random.Generator (Arc2d Length.Meters coordinates)
arc3d : Random.Generator (Arc3d Length.Meters coordinates)
circle2d : Random.Generator (Circle2d Length.Meters coordinates)
circle3d : Random.Generator (Circle3d Length.Meters coordinates)
ellipticalArc2d : Random.Generator (EllipticalArc2d Length.Meters coordinates)
ellipticalArc3d : Random.Generator (EllipticalArc3d Length.Meters coordinates)
ellipse2d : Random.Generator (Ellipse2d Length.Meters coordinates)
quadraticSpline2d : Random.Generator (QuadraticSpline2d Length.Meters coordinates)
quadraticSpline3d : Random.Generator (QuadraticSpline3d Length.Meters coordinates)
cubicSpline2d : Random.Generator (CubicSpline2d Length.Meters coordinates)
cubicSpline3d : Random.Generator (CubicSpline3d Length.Meters coordinates)
rationalQuadraticSpline2d : Random.Generator (RationalQuadraticSpline2d Length.Meters coordinates)
rationalQuadraticSpline3d : Random.Generator (RationalQuadraticSpline3d Length.Meters coordinates)
rationalCubicSpline2d : Random.Generator (RationalCubicSpline2d Length.Meters coordinates)
rationalCubicSpline3d : Random.Generator (RationalCubicSpline3d Length.Meters coordinates)
spline2d : Random.Generator (Spline2d Length.Meters coordinates)
spline3d : Random.Generator (Spline3d Length.Meters coordinates)
sphere3d : Random.Generator (Sphere3d Length.Meters coordinates)
cylinder3d : Random.Generator (Cylinder3d Length.Meters coordinates)
cone3d : Random.Generator (Cone3d Length.Meters coordinates)
ellipsoid3d : Random.Generator (Ellipsoid3d Length.Meters coordinates)
smallList : Random.Generator a -> Random.Generator (List a)
Generate a list of 0 to 32 elements, using the given generator for items.