FVector2 / FVector3 / FVector4

FVector2, FVector3, FVector4 — Aspose.3D Python API Reference

Package: aspose.threed.utilities (aspose-3d-foss 26.1.0)

The FVector types are single-precision (float32) vector classes used internally by vertex element data arrays. They trade the memory efficiency of single precision against the double precision of the Vector2, Vector3, Vector4 classes used for scene graph positions. In practice you will most often create these values when populating VertexElementFVector.set_data().

from aspose.threed.utilities import FVector2, FVector3, FVector4

FVector2

A two-component single-precision float vector with x and y components.

class FVector2:
    def __init__(self, x: float = 0.0, y: float = 0.0): ...

Properties

PropertyTypeAccessDescription
xfloatread/writeFirst component.
yfloatread/writeSecond component.

Methods

MethodReturnsDescription
length()floatEuclidean length of the vector: sqrt(x² + y²).
normalize()FVector2Return a unit-length copy. Returns FVector2(0, 0) for the zero vector.
dot(other)floatDot product with other.
FVector2.parse(s)FVector2Parse a space-separated string "x y" into an FVector2.

Supports +, -, * (scalar), / (scalar), and == operators.

Example

from aspose.threed.utilities import FVector2

uv = FVector2(0.5, 0.25)
print(uv.x, uv.y)           # 0.5 0.25
print(uv.length())           # ~0.559
unit = uv.normalize()
print(round(unit.length(), 6))  # 1.0

a = FVector2(1.0, 0.0)
b = FVector2(0.0, 1.0)
print(a.dot(b))              # 0.0

FVector3

A three-component single-precision float vector with x, y, and z components.

class FVector3:
    def __init__(self, x: float = 0.0, y: float = 0.0, z: float = 0.0): ...

FVector3 also accepts a Vector3, Vector4, or FVector4 as its first argument to convert from those types.

Properties

PropertyTypeAccessDescription
xfloatread/writeFirst component.
yfloatread/writeSecond component.
zfloatread/writeThird component.

Supports index access: v[0], v[1], v[2].

Static factory methods

MethodReturnsDescription
FVector3.zero()FVector3(0, 0, 0)
FVector3.one()FVector3(1, 1, 1)
FVector3.unit_x()FVector3(1, 0, 0)
FVector3.unit_y()FVector3(0, 1, 0)
FVector3.unit_z()FVector3(0, 0, 1)

Instance methods

MethodReturnsDescription
normalize()FVector3Return a unit-length copy. Returns the zero vector for zero-length input.

Example

from aspose.threed.utilities import FVector3

n = FVector3(0.0, 1.0, 0.0)
print(n.normalize())         # FVector3(0.0, 1.0, 0.0)

up = FVector3.unit_y()
print(up.x, up.y, up.z)     # 0.0 1.0 0.0

# Convert from Vector3
from aspose.threed.utilities import Vector3
v = Vector3(1.0, 2.0, 3.0)
fv = FVector3(v)
print(fv)                    # FVector3(1.0, 2.0, 3.0)

FVector4

A four-component single-precision float vector with x, y, z, and w components. This is the storage type used by VertexElementFVector.data.

class FVector4:
    def __init__(self, x: float = 0.0, y: float = 0.0, z: float = 0.0, w: float = 0.0): ...

FVector4 also accepts an FVector3, Vector3, or Vector4 as its first argument.

Properties

PropertyTypeAccessDescription
xfloatread/writeFirst component.
yfloatread/writeSecond component.
zfloatread/writeThird component.
wfloatread/writeFourth component.

Supports index access: v[0] through v[3].

Example

from aspose.threed.utilities import FVector4, FVector3

# Direct construction
normal = FVector4(0.0, 0.0, 1.0, 0.0)
print(normal.z)              # 1.0

# From FVector3
fv3 = FVector3(0.0, 1.0, 0.0)
fv4 = FVector4(fv3, 0.0)
print(fv4)                   # FVector4(0.0, 1.0, 0.0, 0.0)

# Index access
print(fv4[1])                # 1.0
fv4[3] = 1.0
print(fv4.w)                 # 1.0

Relationship to double-precision vectors

Single-precisionDouble-precisionTypical use
FVector2Vector2UV coordinates stored in vertex elements
FVector3Vector3Normals, tangents stored in vertex elements
FVector4Vector4All VertexElementFVector.data entries; also control point conversion

When setting vertex element data, you can pass either precision class. set_data() converts Vector2/Vector3 values to FVector4 automatically.


See Also