Show / Hide Table of Contents

Struct BoundingBox

Oriented quadrilateral in image pixel space (Y down). Corner order matches OneOCR: P1→P2 along the top (reading direction), P3→P4 along the bottom back.

Implements
IEquatable<BoundingBox>
Inherited Members
object.Equals(object, object)
object.GetType()
object.ReferenceEquals(object, object)
Namespace: Zaya.Primitives
Assembly: Zaya.Primitives.dll
Syntax
public readonly struct BoundingBox : IEquatable<BoundingBox>
Remarks

P1 ----→ P2
↑ ↓
P4 ←---- P3

Direction and AngleDegrees are derived from the average of the top edge (P2−P1) and bottom edge (P3−P4).

Constructors

| Edit this page View Source

BoundingBox(Vector2, Vector2, Vector2, Vector2)

Creates a bounding box from four corners in OneOCR order.

Declaration
public BoundingBox(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4)
Parameters
Type Name Description
Vector2 p1
Vector2 p2
Vector2 p3
Vector2 p4

Properties

| Edit this page View Source

AngleDegrees

Tilt of Direction from +X, in degrees (image space, Y down).

Declaration
public float AngleDegrees { get; }
Property Value
Type Description
float
| Edit this page View Source

Bottom

Integer bottom of the AABB (ceil of MaxY).

Declaration
public int Bottom { get; }
Property Value
Type Description
int
| Edit this page View Source

Direction

Unit vector along reading direction: normalize((P2−P1)+(P3−P4)). Falls back to (1,0) when both edges are degenerate.

Declaration
public Vector2 Direction { get; }
Property Value
Type Description
Vector2
| Edit this page View Source

Empty

Empty box (all corners at origin).

Declaration
public static BoundingBox Empty { get; }
Property Value
Type Description
BoundingBox
| Edit this page View Source

Height

Integer AABB height.

Declaration
public int Height { get; }
Property Value
Type Description
int
| Edit this page View Source

IsEmpty

True when all corners are at the origin and the box has no extent.

Declaration
public bool IsEmpty { get; }
Property Value
Type Description
bool
| Edit this page View Source

Left

Same as X.

Declaration
public int Left { get; }
Property Value
Type Description
int
| Edit this page View Source

MaxX

Maximum X of the axis-aligned bounds.

Declaration
public float MaxX { get; }
Property Value
Type Description
float
| Edit this page View Source

MaxY

Maximum Y of the axis-aligned bounds.

Declaration
public float MaxY { get; }
Property Value
Type Description
float
| Edit this page View Source

MinX

Minimum X of the axis-aligned bounds.

Declaration
public float MinX { get; }
Property Value
Type Description
float
| Edit this page View Source

MinY

Minimum Y of the axis-aligned bounds.

Declaration
public float MinY { get; }
Property Value
Type Description
float
| Edit this page View Source

Normal

Unit normal rotated 90° from Direction (points toward the bottom of the glyph in image space for LTR horizontal text).

Declaration
public Vector2 Normal { get; }
Property Value
Type Description
Vector2
| Edit this page View Source

P1

Start of the top edge (reading start).

Declaration
public Vector2 P1 { get; }
Property Value
Type Description
Vector2
| Edit this page View Source

P2

End of the top edge (reading end).

Declaration
public Vector2 P2 { get; }
Property Value
Type Description
Vector2
| Edit this page View Source

P3

End of the bottom edge.

Declaration
public Vector2 P3 { get; }
Property Value
Type Description
Vector2
| Edit this page View Source

P4

Start of the bottom edge.

Declaration
public Vector2 P4 { get; }
Property Value
Type Description
Vector2
| Edit this page View Source

P5

Midpoint of the leading edge (P1–P4): start of the word along reading direction.

Declaration
public Vector2 P5 { get; }
Property Value
Type Description
Vector2
| Edit this page View Source

P6

Midpoint of the trailing edge (P2–P3): end of the word along reading direction.

Declaration
public Vector2 P6 { get; }
Property Value
Type Description
Vector2
| Edit this page View Source

P7

Midpoint of the top edge (P1–P2).

Declaration
public Vector2 P7 { get; }
Property Value
Type Description
Vector2
| Edit this page View Source

P8

Midpoint of the bottom edge (P4–P3).

Declaration
public Vector2 P8 { get; }
Property Value
Type Description
Vector2
| Edit this page View Source

Right

Integer right of the AABB (ceil of MaxX).

Declaration
public int Right { get; }
Property Value
Type Description
int
| Edit this page View Source

TextHeight

Glyph height along the normal (distance between top and bottom edge midpoints).

Declaration
public float TextHeight { get; }
Property Value
Type Description
float
| Edit this page View Source

Top

Same as Y.

Declaration
public int Top { get; }
Property Value
Type Description
int
| Edit this page View Source

Width

Integer AABB width.

Declaration
public int Width { get; }
Property Value
Type Description
int
| Edit this page View Source

X

Integer left of the AABB (floor of MinX).

Declaration
public int X { get; }
Property Value
Type Description
int
| Edit this page View Source

Y

Integer top of the AABB (floor of MinY).

Declaration
public int Y { get; }
Property Value
Type Description
int

Methods

| Edit this page View Source

Equals(object?)

Indicates whether this instance and a specified object are equal.

Declaration
public override bool Equals(object? obj)
Parameters
Type Name Description
object obj

The object to compare with the current instance.

Returns
Type Description
bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

Overrides
ValueType.Equals(object)
| Edit this page View Source

Equals(BoundingBox)

Indicates whether the current object is equal to another object of the same type.

Declaration
public bool Equals(BoundingBox other)
Parameters
Type Name Description
BoundingBox other

An object to compare with this object.

Returns
Type Description
bool

true if the current object is equal to the other parameter; otherwise, false.

| Edit this page View Source

FromAxisAligned(int, int, int, int)

Creates an axis-aligned box from integer pixel coordinates.

Declaration
public static BoundingBox FromAxisAligned(int x, int y, int width, int height)
Parameters
Type Name Description
int x
int y
int width
int height
Returns
Type Description
BoundingBox
| Edit this page View Source

FromAxisAligned(float, float, float, float)

Creates an axis-aligned box (P1 top-left → P2 top-right → P3 bottom-right → P4 bottom-left).

Declaration
public static BoundingBox FromAxisAligned(float x, float y, float width, float height)
Parameters
Type Name Description
float x
float y
float width
float height
Returns
Type Description
BoundingBox
| Edit this page View Source

FromLTRB(int, int, int, int)

Creates an axis-aligned box from left/top/right/bottom edges.

Declaration
public static BoundingBox FromLTRB(int left, int top, int right, int bottom)
Parameters
Type Name Description
int left
int top
int right
int bottom
Returns
Type Description
BoundingBox
| Edit this page View Source

GetHashCode()

Returns the hash code for this instance.

Declaration
public override int GetHashCode()
Returns
Type Description
int

A 32-bit signed integer that is the hash code for this instance.

Overrides
ValueType.GetHashCode()
| Edit this page View Source

ToRect()

Returns the integer axis-aligned rectangle (X, Y, Width, Height).

Declaration
public (int X, int Y, int Width, int Height) ToRect()
Returns
Type Description
(int X, int Y, int Width, int Height)
| Edit this page View Source

ToString()

Returns the fully qualified type name of this instance.

Declaration
public override string ToString()
Returns
Type Description
string

The fully qualified type name.

Overrides
ValueType.ToString()

Operators

| Edit this page View Source

operator ==(BoundingBox, BoundingBox)

Equality operator.

Declaration
public static bool operator ==(BoundingBox left, BoundingBox right)
Parameters
Type Name Description
BoundingBox left
BoundingBox right
Returns
Type Description
bool
| Edit this page View Source

operator !=(BoundingBox, BoundingBox)

Inequality operator.

Declaration
public static bool operator !=(BoundingBox left, BoundingBox right)
Parameters
Type Name Description
BoundingBox left
BoundingBox right
Returns
Type Description
bool

Implements

IEquatable<T>
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX