Table of Contents

Struct ViewportF

Namespace
HelixToolkit.Maths
Assembly
HelixToolkit.Maths.dll

Defines the viewport dimensions using float coordinates for (X,Y,Width,Height).

public struct ViewportF : IEquatable<ViewportF>
Implements
Inherited Members
Extension Methods

Constructors

ViewportF(RectangleF)

Initializes a new instance of the ViewportF struct.

public ViewportF(RectangleF bounds)

Parameters

bounds RectangleF

A bounding box that defines the location and size of the viewport in a render target.

ViewportF(float, float, float, float)

Initializes a new instance of the ViewportF struct.

public ViewportF(float x, float y, float width, float height)

Parameters

x float

The x coordinate of the upper-left corner of the viewport in pixels.

y float

The y coordinate of the upper-left corner of the viewport in pixels.

width float

The width of the viewport in pixels.

height float

The height of the viewport in pixels.

ViewportF(float, float, float, float, float, float)

Initializes a new instance of the ViewportF struct.

public ViewportF(float x, float y, float width, float height, float minDepth, float maxDepth)

Parameters

x float

The x coordinate of the upper-left corner of the viewport in pixels.

y float

The y coordinate of the upper-left corner of the viewport in pixels.

width float

The width of the viewport in pixels.

height float

The height of the viewport in pixels.

minDepth float

The minimum depth of the clip volume.

maxDepth float

The maximum depth of the clip volume.

Fields

Height

Height dimension of the viewport.

public float Height

Field Value

float

MaxDepth

Gets or sets the maximum depth of the clip volume.

public float MaxDepth

Field Value

float

MinDepth

Gets or sets the minimum depth of the clip volume.

public float MinDepth

Field Value

float

Width

Width dimension of the viewport.

public float Width

Field Value

float

X

Position of the pixel coordinate of the upper-left corner of the viewport.

public float X

Field Value

float

Y

Position of the pixel coordinate of the upper-left corner of the viewport.

public float Y

Field Value

float

Properties

AspectRatio

Gets the aspect ratio used by the viewport.

public readonly float AspectRatio { get; }

Property Value

float

The aspect ratio.

Bounds

Gets the size of this resource.

public RectangleF Bounds { readonly get; set; }

Property Value

RectangleF

The bounds.

Methods

Equals(ViewportF)

Determines whether the specified ViewportF is equal to this instance.

public readonly bool Equals(ViewportF other)

Parameters

other ViewportF

The ViewportF to compare with this instance.

Returns

bool

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

Equals(ref ViewportF)

Determines whether the specified ViewportF is equal to this instance.

public readonly bool Equals(ref ViewportF other)

Parameters

other ViewportF

The ViewportF to compare with this instance.

Returns

bool

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

Equals(object?)

Determines whether the specified object is equal to this instance.

public override readonly bool Equals(object? obj)

Parameters

obj object

The object to compare with this instance.

Returns

bool

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

GetHashCode()

Returns a hash code for this instance.

public override readonly int GetHashCode()

Returns

int

A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

Project(Vector3, Matrix4x4, Matrix4x4, Matrix4x4)

Projects a 3D vector from object space into screen space.

public readonly Vector3 Project(Vector3 source, Matrix4x4 projection, Matrix4x4 view, Matrix4x4 world)

Parameters

source Vector3

The vector to project.

projection Matrix4x4

The projection matrix.

view Matrix4x4

The view matrix.

world Matrix4x4

The world matrix.

Returns

Vector3

The projected vector.

Project(ref Vector3, ref Matrix4x4, out Vector3)

Projects a 3D vector from object space into screen space.

public readonly void Project(ref Vector3 source, ref Matrix4x4 matrix, out Vector3 vector)

Parameters

source Vector3

The vector to project.

matrix Matrix4x4

A combined WorldViewProjection matrix.

vector Vector3

The projected vector.

ToString()

Retrieves a string representation of this object.

public override readonly string ToString()

Returns

string

A string that represents this instance.

Unproject(Vector3, Matrix4x4, Matrix4x4, Matrix4x4)

Converts a screen space point into a corresponding point in world space.

public readonly Vector3 Unproject(Vector3 source, Matrix4x4 projection, Matrix4x4 view, Matrix4x4 world)

Parameters

source Vector3

The vector to project.

projection Matrix4x4

The projection matrix.

view Matrix4x4

The view matrix.

world Matrix4x4

The world matrix.

Returns

Vector3

The unprojected Vector.

Unproject(ref Vector3, ref Matrix4x4, out Vector3)

Converts a screen space point into a corresponding point in world space.

public readonly void Unproject(ref Vector3 source, ref Matrix4x4 matrix, out Vector3 vector)

Parameters

source Vector3

The vector to project.

matrix Matrix4x4

An inverted combined WorldViewProjection matrix.

vector Vector3

The unprojected vector.

Operators

operator ==(ViewportF, ViewportF)

Implements the operator ==.

public static bool operator ==(ViewportF left, ViewportF right)

Parameters

left ViewportF

The left.

right ViewportF

The right.

Returns

bool

The result of the operator.

implicit operator ViewportF(Viewport)

Performs an explicit conversion from Viewport to ViewportF.

public static implicit operator ViewportF(Viewport value)

Parameters

value Viewport

The value.

Returns

ViewportF

The result of the conversion.

operator !=(ViewportF, ViewportF)

Implements the operator !=.

public static bool operator !=(ViewportF left, ViewportF right)

Parameters

left ViewportF

The left.

right ViewportF

The right.

Returns

bool

The result of the operator.