Class RectangularRegion
- Namespace
- VirtualLabAPI.Core.Numerics.Region2D
- Assembly
- VirtualLabAPI.dll
Class which describes a rectangular region which may be situated at an arbitrary center and which may be rotated by an arbitrary angle.
[Serializable]
public class RectangularRegion : ElementaryRegion2D, ISerializable, IDeserializationCallback, IRegion1D2D, IDocument, IEquatable<IObjectBase>, IDisposable, ICloneable
- Inheritance
-
ObjectBaseSerializableObjectBaseManualSerializationDocumentBaseRectangularRegion
- Implements
-
IEquatable<IObjectBase>
- Inherited Members
- Extension Methods
Constructors
RectangularRegion()
Default constructor, creating a a non-rotated rectangle of 10mm x 5mm and centered at (0,0).
public RectangularRegion()
RectangularRegion(RectanglePhysical, bool)
Constructor which creates region from RectanglePhysical
public RectangularRegion(RectanglePhysical rectangle, bool boundariesAreInside)
Parameters
rectangleRectanglePhysicalRectanglePhysical to be represented as region.
boundariesAreInsideboolIf true, values lying exactly on the boundaries are considered as being 'inside' the region.
RectangularRegion(RectangularRegion)
Copy constructor
public RectangularRegion(RectangularRegion rectRegion)
Parameters
rectRegionRectangularRegionThe rectangular region to be copied.
RectangularRegion(VectorD, double, double, double, bool, bool, PhysicalProperty, PhysicalProperty)
Constructor with all field parameters.
public RectangularRegion(VectorD location, double width, double height, double angle, bool bottomLeftCoordinateInsteadOfCenterGiven, bool boundaryIsInside = false, PhysicalProperty propertyOfCoordinatesX = PhysicalProperty.Length, PhysicalProperty propertyOfCoordinatesY = PhysicalProperty.Length)
Parameters
locationVectorDThe center of the rectangle in case bottomLeftCoordinateInsteadOfCenterGiven == false. Otherwise this parameter gives the bottom left corner.
widthdoubleWidth of the rectangle.
heightdoubleHeight of the rectangle.
angledoubleRotation angle (in radians) of the rectangle: The rotation is done about the given location. The angle is defined between the width-side and the x-axis, as well as between the height-side and the y-axis.
bottomLeftCoordinateInsteadOfCenterGivenboolIf true, the first parameter is not the center but the bottom left corner of the unrotated rectangle. Important: The rotation by angle is done around the location, no matter if it is the center or not.
boundaryIsInsideboolFlag which says whether or not the boundary is part of the inner region or not.
propertyOfCoordinatesXPhysicalPropertyPhysical property of the x-coordinate.
propertyOfCoordinatesYPhysicalPropertyPhysical property of the y-coordinate.
Fields
VertexNameLowerLeft
Standard vertex name for lower left vertices in equidistant segmentation of polygons.
public const string VertexNameLowerLeft = "ll"
Field Value
VertexNameLowerRight
Standard vertex name for lower right vertices in equidistant segmentation of polygons.
public const string VertexNameLowerRight = "lr"
Field Value
VertexNameUpperLeft
Standard vertex name for upper left vertices in equidistant segmentation of polygons.
public const string VertexNameUpperLeft = "ul"
Field Value
VertexNameUpperRight
Standard vertex name for upper right vertices in equidistant segmentation of polygons.
public const string VertexNameUpperRight = "ur"
Field Value
Properties
Angle
Gets the rotation angle in radians.
public double Angle { get; set; }
Property Value
Center
Gets the center of the rectangle.
public VectorD Center { get; set; }
Property Value
Height
Gets the height of the rectangle.
public double Height { get; set; }
Property Value
ParameterRunParameters
Gets all available parameters. For variable parameters (i.e. those double and int parameters which can be used in the Parameter Run, Parametric Optimization and so on) add a VaryParameterInfo object (derived from Parameter class) to the returned list.
public virtual List<Parameter> ParameterRunParameters { get; }
Property Value
- List<Parameter>
VerticesConsideringRotation
Gets the four vertices of the rectangle considering its rotation by AngleInDegrees.
public VectorD[] VerticesConsideringRotation { get; }
Property Value
- VectorD[]
Width
Gets the width of the rectangle.
public double Width { get; set; }
Property Value
Methods
CalculateAxisAlignedBoundingBox()
Method for (re)calculating the axis aligned bounding box.
public override void CalculateAxisAlignedBoundingBox()
CalculateDistanceOfPointToRegionBorder(VectorD)
Calculates the distance of a point to the border of this region.
public override double CalculateDistanceOfPointToRegionBorder(VectorD point)
Parameters
pointVectorDPoint to calculate the distance for.
Returns
- double
The distance of the given point to the border of this region
Clone()
Deep copy of the object.
public override object Clone()
Returns
- object
A deep copy of this.
Equals(object, EqualityIntent)
Determines whether the specified object is equal to this instance.
public override bool Equals(object obj, EqualityIntent equalityIntent)
Parameters
objobjectequalityIntentEqualityIntentDefines what kind of equality you want to check when comparing two objects, for example all values or just physical equality.
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
GetInOutRelation(VectorD, ExtrapolationInfo)
Method which checks whether or not a point lies inside or outside the 2D region or on its boundary.
public override InsideOutside GetInOutRelation(VectorD point, ExtrapolationInfo extrapolation2use = null)
Parameters
pointVectorDThe point to be checked whether it lies inside.
extrapolation2useExtrapolationInfoExtrapolation info actually to be used.
Returns
- InsideOutside
Information where the point lies in relation to the region.
MayBeNonzeroOutside(out bool, out bool, out bool, out bool)
Method which determines whether or not the region can provide "inside" state outside of its boundary interval. This is not the case for extrapolation mode 'ConstantZero', of course.
public override void MayBeNonzeroOutside(out bool maybeNonZeroLeft, out bool maybeNonZeroRight, out bool maybeNonZeroBottom, out bool maybeNonZeroTop)
Parameters
maybeNonZeroLeftboolTrue, if there may be nonzero values left of the bounding box.maybeNonZeroRightboolTrue, if there may be nonzero values right of the bounding box.maybeNonZeroBottomboolTrue, if there may be nonzero values below the bottom of the bounding box.maybeNonZeroTopboolTrue, if there may be nonzero values above the top of the bounding box.
Rotate(double, VectorD)
Method for transforming a given rectangular region by rotating by an angle around a given rotation center.
public void Rotate(double angle, VectorD centerOfRotation)
Parameters
angledoubleThe angle to rotate the polygon with (given in radian).
centerOfRotationVectorDThe center to rotate the polygon around.
ScaleByFactors(VectorD, bool)
Scales the region by the given factor.
public override void ScaleByFactors(VectorD factors, bool keepCenter)
Parameters
factorsVectorDThe scaling factors for both x- and y-direction.
keepCenterboolWhether the center of the region remains unchanged (true) or is scaled by the same factors (false).
Shift(VectorD)
Shifts this region by the given vector.
public override void Shift(VectorD shift)
Parameters
shiftVectorDThe shift added to the current position of the region.
UpdatePropertyOfCoordinates()
Method for handling update after change of the physical property of the coordinate
public override void UpdatePropertyOfCoordinates()
Operators
operator ==(RectangularRegion, RectangularRegion)
Equality operator.
public static bool operator ==(RectangularRegion o1, RectangularRegion o2)
Parameters
o1RectangularRegionThe first region.
o2RectangularRegionThe second region.
Returns
- bool
Whether the two regions are equal.
implicit operator SimplePolygon(RectangularRegion)
Implicit cast from rectangle to simple polygon.
public static implicit operator SimplePolygon(RectangularRegion rectangularRegion)
Parameters
rectangularRegionRectangularRegionRectangle to be converted into a polygon.
Returns
- SimplePolygon
This rectangular region as SimplePolygon.
operator !=(RectangularRegion, RectangularRegion)
Inequality operator.
public static bool operator !=(RectangularRegion o1, RectangularRegion o2)
Parameters
o1RectangularRegionThe first region.
o2RectangularRegionThe second region.
Returns
- bool
Whether the two regions are unequal.