Table of Contents

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
ObjectBase
SerializableObjectBase
ManualSerialization
DocumentBase
RectangularRegion
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

rectangle RectanglePhysical

RectanglePhysical to be represented as region.

boundariesAreInside bool

If true, values lying exactly on the boundaries are considered as being 'inside' the region.

RectangularRegion(RectangularRegion)

Copy constructor

public RectangularRegion(RectangularRegion rectRegion)

Parameters

rectRegion RectangularRegion

The 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

location VectorD

The center of the rectangle in case bottomLeftCoordinateInsteadOfCenterGiven == false. Otherwise this parameter gives the bottom left corner.

width double

Width of the rectangle.

height double

Height of the rectangle.

angle double

Rotation 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.

bottomLeftCoordinateInsteadOfCenterGiven bool

If 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.

boundaryIsInside bool

Flag which says whether or not the boundary is part of the inner region or not.

propertyOfCoordinatesX PhysicalProperty

Physical property of the x-coordinate.

propertyOfCoordinatesY PhysicalProperty

Physical 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

string

VertexNameLowerRight

Standard vertex name for lower right vertices in equidistant segmentation of polygons.

public const string VertexNameLowerRight = "lr"

Field Value

string

VertexNameUpperLeft

Standard vertex name for upper left vertices in equidistant segmentation of polygons.

public const string VertexNameUpperLeft = "ul"

Field Value

string

VertexNameUpperRight

Standard vertex name for upper right vertices in equidistant segmentation of polygons.

public const string VertexNameUpperRight = "ur"

Field Value

string

Properties

Angle

Gets the rotation angle in radians.

public double Angle { get; set; }

Property Value

double

Center

Gets the center of the rectangle.

public VectorD Center { get; set; }

Property Value

VectorD

Height

Gets the height of the rectangle.

public double Height { get; set; }

Property Value

double

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

double

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

point VectorD

Point 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

obj object
equalityIntent EqualityIntent

Defines what kind of equality you want to check when comparing two objects, for example all values or just physical equality.

Returns

bool

true if the specified object is equal to this instance; otherwise, false.

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

point VectorD

The point to be checked whether it lies inside.

extrapolation2use ExtrapolationInfo

Extrapolation 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

maybeNonZeroLeft bool

True, if there may be nonzero values left of the bounding box.

maybeNonZeroRight bool

True, if there may be nonzero values right of the bounding box.

maybeNonZeroBottom bool

True, if there may be nonzero values below the bottom of the bounding box.

maybeNonZeroTop bool

True, 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

angle double

The angle to rotate the polygon with (given in radian).

centerOfRotation VectorD

The 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

factors VectorD

The scaling factors for both x- and y-direction.

keepCenter bool

Whether 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

shift VectorD

The 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

o1 RectangularRegion

The first region.

o2 RectangularRegion

The 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

rectangularRegion RectangularRegion

Rectangle 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

o1 RectangularRegion

The first region.

o2 RectangularRegion

The second region.

Returns

bool

Whether the two regions are unequal.