Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/

API Reference

Class

OfficeGeometry

Namespace OfficeIMO.Drawing
Assembly OfficeIMO.Core
Modifiers static

Reusable dependency-free geometry helpers shared by OfficeIMO renderers.

Inheritance

  • Object
  • OfficeGeometry

Methods

BuildConnectorPolyline 2 overloads
public static List<OfficePoint> BuildConnectorPolyline(OfficePoint start, OfficePoint end, IReadOnlyList<OfficePoint> waypoints, Boolean useRightAngleFallback) #
Returns: List<OfficePoint>

Builds a connector polyline from endpoints, optional waypoints, and optional right-angle fallback routing.

Parameters

start OfficeIMO.Drawing.OfficePoint requiredposition: 0
Connector start point.
end OfficeIMO.Drawing.OfficePoint requiredposition: 1
Connector end point.
waypoints System.Collections.Generic.IReadOnlyList{OfficeIMO.Drawing.OfficePoint} requiredposition: 2
Explicit intermediate points. When present, these take precedence over right-angle fallback routing.
useRightAngleFallback System.Boolean requiredposition: 3
When true and no explicit waypoints exist, inserts one orthogonal elbow at start X and end Y.

Returns

A connector polyline containing start, any intermediate points, and end.

public static List<ValueTuple<Double, Double>> BuildConnectorPolyline(ValueTuple<Double, Double> start, ValueTuple<Double, Double> end, IReadOnlyList<ValueTuple<Double, Double>> waypoints, Boolean useRightAngleFallback) #
Returns: List<ValueTuple<Double, Double>>

Builds a tuple connector polyline from endpoints, optional waypoints, and optional right-angle fallback routing.

Parameters

start System.ValueTuple{System.Double,System.Double} requiredposition: 0
Connector start point.
end System.ValueTuple{System.Double,System.Double} requiredposition: 1
Connector end point.
waypoints System.Collections.Generic.IReadOnlyList{System.ValueTuple{System.Double,System.Double}} requiredposition: 2
Explicit intermediate points. When present, these take precedence over right-angle fallback routing.
useRightAngleFallback System.Boolean requiredposition: 3
When true and no explicit waypoints exist, inserts one orthogonal elbow at start X and end Y.

Returns

A connector polyline containing start, any intermediate points, and end.

CreateCubicBezierPoints 2 overloads
public static List<OfficePoint> CreateCubicBezierPoints(OfficePoint start, OfficePoint control1, OfficePoint control2, OfficePoint end, Int32 segments) #
Returns: List<OfficePoint>

Samples a cubic Bezier curve into straight-line points, excluding the start point and including the end point.

Parameters

start OfficeIMO.Drawing.OfficePoint requiredposition: 0
Curve start point.
control1 OfficeIMO.Drawing.OfficePoint requiredposition: 1
First cubic control point.
control2 OfficeIMO.Drawing.OfficePoint requiredposition: 2
Second cubic control point.
end OfficeIMO.Drawing.OfficePoint requiredposition: 3
Curve end point.
segments System.Int32 requiredposition: 4
Number of line segments used to approximate the curve.
public static List<ValueTuple<Double, Double>> CreateCubicBezierPoints(ValueTuple<Double, Double> start, ValueTuple<Double, Double> control1, ValueTuple<Double, Double> control2, ValueTuple<Double, Double> end, Int32 segments) #
Returns: List<ValueTuple<Double, Double>>

Samples a tuple cubic Bezier curve into straight-line points, excluding the start point and including the end point.

Parameters

start System.ValueTuple{System.Double,System.Double} requiredposition: 0
Curve start point.
control1 System.ValueTuple{System.Double,System.Double} requiredposition: 1
First cubic control point.
control2 System.ValueTuple{System.Double,System.Double} requiredposition: 2
Second cubic control point.
end System.ValueTuple{System.Double,System.Double} requiredposition: 3
Curve end point.
segments System.Int32 requiredposition: 4
Number of line segments used to approximate the curve.
public static List<OfficePathCommand> CreateEllipticalArcCubicBezierCommands(OfficePoint start, Double radiusX, Double radiusY, Double startRadians, Double sweepRadians) #
Returns: List<OfficePathCommand>

Converts an elliptical arc into cubic Bezier path commands, excluding the current move point.

Parameters

start OfficeIMO.Drawing.OfficePoint requiredposition: 0
Current path point. It must represent the point at startRadians on the ellipse.
radiusX System.Double requiredposition: 1
Horizontal ellipse radius.
radiusY System.Double requiredposition: 2
Vertical ellipse radius.
startRadians System.Double requiredposition: 3
Start angle in radians, using the renderer's y-down coordinate system.
sweepRadians System.Double requiredposition: 4
Sweep angle in radians. Positive values sweep clockwise in y-down coordinates.

Returns

Cubic Bezier commands that approximate the requested arc.

public static List<OfficePoint> CreateEllipticalArcPoints(Double centerX, Double centerY, Double radiusX, Double radiusY, Double startRadians, Double sweepRadians, Int32 segments, Double rotationRadians = 0, Double rotationCenterX = 0, Double rotationCenterY = 0) #
Returns: List<OfficePoint>

Samples an elliptical arc into straight-line points, excluding the start point and including the end point.

Parameters

centerX System.Double requiredposition: 0
Arc center X coordinate.
centerY System.Double requiredposition: 1
Arc center Y coordinate.
radiusX System.Double requiredposition: 2
Horizontal radius before optional rotation.
radiusY System.Double requiredposition: 3
Vertical radius before optional rotation.
startRadians System.Double requiredposition: 4
Start angle in radians.
sweepRadians System.Double requiredposition: 5
Sweep angle in radians.
segments System.Int32 requiredposition: 6
Number of line segments used to approximate the arc.
rotationRadians System.Double = 0 optionalposition: 7
Optional rotation angle in radians.
rotationCenterX System.Double = 0 optionalposition: 8
Rotation center X coordinate.
rotationCenterY System.Double = 0 optionalposition: 9
Rotation center Y coordinate.
public static List<ValueTuple<Double, Double>> CreateEllipticalArcPointsAsTuples(Double centerX, Double centerY, Double radiusX, Double radiusY, Double startRadians, Double sweepRadians, Int32 segments, Double rotationRadians = 0, Double rotationCenterX = 0, Double rotationCenterY = 0) #
Returns: List<ValueTuple<Double, Double>>

Samples a tuple elliptical arc into straight-line points, excluding the start point and including the end point.

Parameters

centerX System.Double requiredposition: 0
Arc center X coordinate.
centerY System.Double requiredposition: 1
Arc center Y coordinate.
radiusX System.Double requiredposition: 2
Horizontal radius before optional rotation.
radiusY System.Double requiredposition: 3
Vertical radius before optional rotation.
startRadians System.Double requiredposition: 4
Start angle in radians.
sweepRadians System.Double requiredposition: 5
Sweep angle in radians.
segments System.Int32 requiredposition: 6
Number of line segments used to approximate the arc.
rotationRadians System.Double = 0 optionalposition: 7
Optional rotation angle in radians.
rotationCenterX System.Double = 0 optionalposition: 8
Rotation center X coordinate.
rotationCenterY System.Double = 0 optionalposition: 9
Rotation center Y coordinate.
CreateQuadraticBezierPoints 2 overloads
public static List<OfficePoint> CreateQuadraticBezierPoints(OfficePoint start, OfficePoint control, OfficePoint end, Int32 segments) #
Returns: List<OfficePoint>

Samples a quadratic Bezier curve into straight-line points, excluding the start point and including the end point.

Parameters

start OfficeIMO.Drawing.OfficePoint requiredposition: 0
Curve start point.
control OfficeIMO.Drawing.OfficePoint requiredposition: 1
Quadratic control point.
end OfficeIMO.Drawing.OfficePoint requiredposition: 2
Curve end point.
segments System.Int32 requiredposition: 3
Number of line segments used to approximate the curve.
public static List<ValueTuple<Double, Double>> CreateQuadraticBezierPoints(ValueTuple<Double, Double> start, ValueTuple<Double, Double> control, ValueTuple<Double, Double> end, Int32 segments) #
Returns: List<ValueTuple<Double, Double>>

Samples a tuple quadratic Bezier curve into straight-line points, excluding the start point and including the end point.

Parameters

start System.ValueTuple{System.Double,System.Double} requiredposition: 0
Curve start point.
control System.ValueTuple{System.Double,System.Double} requiredposition: 1
Quadratic control point.
end System.ValueTuple{System.Double,System.Double} requiredposition: 2
Curve end point.
segments System.Int32 requiredposition: 3
Number of line segments used to approximate the curve.
public static Double DegreesToRadians(Double degrees) #
Returns: Double

Converts degrees to radians.

Parameters

degrees System.Double requiredposition: 0
Angle in degrees.

Returns

The same angle in radians.

Distance 3 overloads
public static Double Distance(Double x1, Double y1, Double x2, Double y2) #
Returns: Double

Calculates the Euclidean distance between two points.

Parameters

x1 System.Double requiredposition: 0
y1 System.Double requiredposition: 1
x2 System.Double requiredposition: 2
y2 System.Double requiredposition: 3
public static Double Distance(OfficePoint from, OfficePoint to) #
Returns: Double

Calculates the Euclidean distance between two points.

Parameters

from OfficeIMO.Drawing.OfficePoint requiredposition: 0
to OfficeIMO.Drawing.OfficePoint requiredposition: 1
public static Double Distance(ValueTuple<Double, Double> from, ValueTuple<Double, Double> to) #
Returns: Double

Calculates the Euclidean distance between two tuple points.

Parameters

from System.ValueTuple{System.Double,System.Double} requiredposition: 0
to System.ValueTuple{System.Double,System.Double} requiredposition: 1
public static ValueTuple<Double, Double, Double, Double> GetRotatedRectangleBounds(Double x, Double y, Double width, Double height, Double rotationDegrees, Double centerX, Double centerY) #
Returns: ValueTuple<Double, Double, Double, Double>

Calculates axis-aligned bounds for a rectangle after rotation around a supplied center.

Parameters

x System.Double requiredposition: 0
Rectangle left coordinate.
y System.Double requiredposition: 1
Rectangle top coordinate.
width System.Double requiredposition: 2
Rectangle width.
height System.Double requiredposition: 3
Rectangle height.
rotationDegrees System.Double requiredposition: 4
Rotation angle in degrees.
centerX System.Double requiredposition: 5
Rotation center X coordinate.
centerY System.Double requiredposition: 6
Rotation center Y coordinate.

Returns

Axis-aligned bounds of the rotated rectangle.

InterpolatePolyline 2 overloads
public static OfficePoint InterpolatePolyline(IReadOnlyList<OfficePoint> points, Double position) #
Returns: OfficePoint

Returns the point at the supplied normalized position along a polyline.

Parameters

points System.Collections.Generic.IReadOnlyList{OfficeIMO.Drawing.OfficePoint} requiredposition: 0
Polyline points in drawing coordinates.
position System.Double requiredposition: 1
Normalized position where 0 is the first point and 1 is the last point.
public static ValueTuple<Double, Double> InterpolatePolyline(IReadOnlyList<ValueTuple<Double, Double>> points, Double position) #
Returns: ValueTuple<Double, Double>

Returns the tuple point at the supplied normalized position along a polyline.

Parameters

points System.Collections.Generic.IReadOnlyList{System.ValueTuple{System.Double,System.Double}} requiredposition: 0
Polyline points in drawing coordinates.
position System.Double requiredposition: 1
Normalized position where 0 is the first point and 1 is the last point.
public static Double RadiansToDegrees(Double radians) #
Returns: Double

Converts radians to degrees.

Parameters

radians System.Double requiredposition: 0
Angle in radians.

Returns

The same angle in degrees.

ResolveRectangleBoundaryEndpoint 2 overloads
public static OfficePoint ResolveRectangleBoundaryEndpoint(Double sourceLeft, Double sourceBottom, Double sourceRight, Double sourceTop, Double targetLeft, Double targetBottom, Double targetRight, Double targetTop) #
Returns: OfficePoint

Resolves the point on a source rectangle boundary that faces a target rectangle.

Parameters

sourceLeft System.Double requiredposition: 0
Source rectangle left X coordinate.
sourceBottom System.Double requiredposition: 1
Source rectangle minimum Y coordinate.
sourceRight System.Double requiredposition: 2
Source rectangle right X coordinate.
sourceTop System.Double requiredposition: 3
Source rectangle maximum Y coordinate.
targetLeft System.Double requiredposition: 4
Target rectangle left X coordinate.
targetBottom System.Double requiredposition: 5
Target rectangle minimum Y coordinate.
targetRight System.Double requiredposition: 6
Target rectangle right X coordinate.
targetTop System.Double requiredposition: 7
Target rectangle maximum Y coordinate.

Returns

The source boundary point nearest the target rectangle by dominant center direction.

public static Void ResolveRectangleBoundaryEndpoint(Double sourceLeft, Double sourceBottom, Double sourceRight, Double sourceTop, Double targetLeft, Double targetBottom, Double targetRight, Double targetTop, out Double x, out Double y) #
Returns: Void

Resolves coordinates on a source rectangle boundary that faces a target rectangle.

Parameters

sourceLeft System.Double requiredposition: 0
Source rectangle left X coordinate.
sourceBottom System.Double requiredposition: 1
Source rectangle minimum Y coordinate.
sourceRight System.Double requiredposition: 2
Source rectangle right X coordinate.
sourceTop System.Double requiredposition: 3
Source rectangle maximum Y coordinate.
targetLeft System.Double requiredposition: 4
Target rectangle left X coordinate.
targetBottom System.Double requiredposition: 5
Target rectangle minimum Y coordinate.
targetRight System.Double requiredposition: 6
Target rectangle right X coordinate.
targetTop System.Double requiredposition: 7
Target rectangle maximum Y coordinate.
x System.Double@ requiredposition: 8
Resolved source boundary X coordinate.
y System.Double@ requiredposition: 9
Resolved source boundary Y coordinate.
RotatePoint 2 overloads
public static OfficePoint RotatePoint(OfficePoint point, Double centerX, Double centerY, Double rotationRadians) #
Returns: OfficePoint

Rotates a point around the supplied center using radians in raster coordinate space.

Parameters

point OfficeIMO.Drawing.OfficePoint requiredposition: 0
Point to rotate.
centerX System.Double requiredposition: 1
Rotation center X coordinate.
centerY System.Double requiredposition: 2
Rotation center Y coordinate.
rotationRadians System.Double requiredposition: 3
Rotation angle in radians.

Returns

The rotated point.

public static ValueTuple<Double, Double> RotatePoint(ValueTuple<Double, Double> point, Double centerX, Double centerY, Double rotationRadians) #
Returns: ValueTuple<Double, Double>

Rotates a tuple point around the supplied center using radians in raster coordinate space.

Parameters

point System.ValueTuple{System.Double,System.Double} requiredposition: 0
Point to rotate.
centerX System.Double requiredposition: 1
Rotation center X coordinate.
centerY System.Double requiredposition: 2
Rotation center Y coordinate.
rotationRadians System.Double requiredposition: 3
Rotation angle in radians.

Returns

The rotated tuple point.

SegmentIntersectsRectangle 2 overloads
public static Boolean SegmentIntersectsRectangle(ValueTuple<Double, Double> start, ValueTuple<Double, Double> end, Double left, Double bottom, Double right, Double top) #
Returns: Boolean

Determines whether a line segment intersects a rectangle, including boundary touches.

Parameters

start System.ValueTuple{System.Double,System.Double} requiredposition: 0
Segment start point.
end System.ValueTuple{System.Double,System.Double} requiredposition: 1
Segment end point.
left System.Double requiredposition: 2
Rectangle left X coordinate.
bottom System.Double requiredposition: 3
Rectangle lower Y coordinate.
right System.Double requiredposition: 4
Rectangle right X coordinate.
top System.Double requiredposition: 5
Rectangle upper Y coordinate.
public static Boolean SegmentIntersectsRectangle(OfficePoint start, OfficePoint end, Double left, Double bottom, Double right, Double top) #
Returns: Boolean

Determines whether a line segment intersects a rectangle, including boundary touches.

Parameters

start OfficeIMO.Drawing.OfficePoint requiredposition: 0
Segment start point.
end OfficeIMO.Drawing.OfficePoint requiredposition: 1
Segment end point.
left System.Double requiredposition: 2
Rectangle left X coordinate.
bottom System.Double requiredposition: 3
Rectangle lower Y coordinate.
right System.Double requiredposition: 4
Rectangle right X coordinate.
top System.Double requiredposition: 5
Rectangle upper Y coordinate.
SegmentsIntersect 2 overloads
public static Boolean SegmentsIntersect(ValueTuple<Double, Double> firstStart, ValueTuple<Double, Double> firstEnd, ValueTuple<Double, Double> secondStart, ValueTuple<Double, Double> secondEnd) #
Returns: Boolean

Determines whether two line segments intersect, including boundary touches and collinear overlap.

Parameters

firstStart System.ValueTuple{System.Double,System.Double} requiredposition: 0
firstEnd System.ValueTuple{System.Double,System.Double} requiredposition: 1
secondStart System.ValueTuple{System.Double,System.Double} requiredposition: 2
secondEnd System.ValueTuple{System.Double,System.Double} requiredposition: 3
public static Boolean SegmentsIntersect(OfficePoint firstStart, OfficePoint firstEnd, OfficePoint secondStart, OfficePoint secondEnd) #
Returns: Boolean

Determines whether two line segments intersect, including boundary touches and collinear overlap.

Parameters

firstStart OfficeIMO.Drawing.OfficePoint requiredposition: 0
firstEnd OfficeIMO.Drawing.OfficePoint requiredposition: 1
secondStart OfficeIMO.Drawing.OfficePoint requiredposition: 2
secondEnd OfficeIMO.Drawing.OfficePoint requiredposition: 3
public static Boolean TryCreateArrowheadPoints(OfficePoint tip, OfficePoint from, Double strokeWidth, out OfficePoint[] points, Double minimumLength = 8, Double lengthMultiplier = 4, Double wingAngleRadians = 0.4487989505128276) #
Returns: Boolean

Calculates the triangular arrowhead points for a connector segment.

Parameters

tip OfficeIMO.Drawing.OfficePoint requiredposition: 0
Arrowhead tip point.
from OfficeIMO.Drawing.OfficePoint requiredposition: 1
A non-collapsed point behind the tip on the connector segment.
strokeWidth System.Double requiredposition: 2
Connector stroke width used to scale the arrowhead length.
points OfficeIMO.Drawing.OfficePoint[]@ requiredposition: 3
Three arrowhead points: tip, first wing, and second wing.
minimumLength System.Double = 8 optionalposition: 4
Minimum arrowhead length in drawing units.
lengthMultiplier System.Double = 4 optionalposition: 5
Multiplier applied to strokeWidth.
wingAngleRadians System.Double = 0.4487989505128276 optionalposition: 6
Angle between the connector segment and each arrowhead wing.

Returns

true when the segment and sizing inputs can produce an arrowhead.

TryGetArrowheadSegment 2 overloads
public static Boolean TryGetArrowheadSegment(IReadOnlyList<OfficePoint> points, Boolean fromStart, out OfficePoint tip, out OfficePoint from, Double tolerance = 1E-06) #
Returns: Boolean

Finds the terminal non-collapsed segment that should receive an arrowhead.

Parameters

points System.Collections.Generic.IReadOnlyList{OfficeIMO.Drawing.OfficePoint} requiredposition: 0
Connector polyline points in drawing coordinates.
fromStart System.Boolean requiredposition: 1
When true, resolves the first segment; otherwise resolves the last segment.
tip OfficeIMO.Drawing.OfficePoint@ requiredposition: 2
Resolved arrow tip point.
from OfficeIMO.Drawing.OfficePoint@ requiredposition: 3
Resolved point behind the arrow tip.
tolerance System.Double = 1E-06 optionalposition: 4
Minimum segment length considered non-collapsed.

Returns

true when a non-collapsed terminal segment exists.

public static Boolean TryGetArrowheadSegment(IReadOnlyList<ValueTuple<Double, Double>> points, Boolean fromStart, out ValueTuple<Double, Double> tip, out ValueTuple<Double, Double> from, Double tolerance = 1E-06) #
Returns: Boolean

Finds the terminal non-collapsed tuple segment that should receive an arrowhead.

Parameters

points System.Collections.Generic.IReadOnlyList{System.ValueTuple{System.Double,System.Double}} requiredposition: 0
Connector polyline points in drawing coordinates.
fromStart System.Boolean requiredposition: 1
When true, resolves the first segment; otherwise resolves the last segment.
tip System.ValueTuple{System.Double,System.Double}@ requiredposition: 2
Resolved arrow tip point.
from System.ValueTuple{System.Double,System.Double}@ requiredposition: 3
Resolved point behind the arrow tip.
tolerance System.Double = 1E-06 optionalposition: 4
Minimum segment length considered non-collapsed.

Returns

true when a non-collapsed terminal segment exists.

public static Boolean TryGetParallelLineOffsets(Double x1, Double y1, Double x2, Double y2, Double separation, out Double offsetX, out Double offsetY) #
Returns: Boolean

Calculates the perpendicular half-offset for two parallel lines separated by the supplied distance.

Parameters

x1 System.Double requiredposition: 0
Source line start X coordinate.
y1 System.Double requiredposition: 1
Source line start Y coordinate.
x2 System.Double requiredposition: 2
Source line end X coordinate.
y2 System.Double requiredposition: 3
Source line end Y coordinate.
separation System.Double requiredposition: 4
Distance between the two parallel line centers.
offsetX System.Double@ requiredposition: 5
Perpendicular X offset from the source line center to either parallel line.
offsetY System.Double@ requiredposition: 6
Perpendicular Y offset from the source line center to either parallel line.

Returns

true when the source line has usable length and finite coordinates.