d3d11.Vector

A 3-component floating point vector. Supports pickling.

The fourth component w is included because the underlying library uses 4-component vectors. Don’t use it unless otherwise mentioned in the documetation.

Methods

class Vector
Vector() → Vector

Creates a new zero vector.

Vector(x, y, z) → Vector

Creates a new vector from given components.

Vector(source) → Vector

Creates a new vector from another object.

3D Vector methods

angle(Vector v) → float

Returns the radian angle between self and v.

cross(Vector v) → Vector

Returns the cross product between self and v.

direction(Vector v) → Vector

Returns the normalized direction from self to v.

distance(Vector v) → float

Returns the distance between self and v.

distanceLine(Vector linepoint1, Vector linepoint2) → float

Returns the minimum distance between self and a line of infinite length.

dot(Vector v) → float

Returns the dot product between self and v.

length() → float

Returns the length of self.

lerp(Vector v, float t) → Vector
Parameters:
  • t – Interpolation factor from 0.0 to 1.0

Performs a linear interpolation between self and v and returns the result.

normalize() → Vector

Returns a normalized version of self.

project(viewport, projmatrix, viewmatrix, worldmatrix) → Vector
Parameters:
  • viewport – A viewport from d3d11.Device.getViewports().
  • projmatrix – The projection d3d11.Matrix to be used.
  • viewmatrix – The view matrix to be used.
  • worldmatrix – The world matrix to be used.

Projects self from object space (3D) into screen space (2D).

reflect(Vector normal) → Vector

Returns the reflected incident angle vector.

unproject(viewport, projmatrix, viewmatrix, worldmatrix) → Vector

Projects self from screen space (2D) into object space (3D). See project().

3D Vector static methods

static splineCatmullRom(v1, v2, v3, v4, float t) → Vector

Performs a Catmull-Rom spline interpolation.

static splineHermite(v1, t1, v2, t2, float t) → Vector

Performs a hermite spline interpolation.

static triIntersect(v1, v2, v3, raystart, raydir) → Vector
Parameters:
  • raystart – Starting point for the ray.
  • raydir – Ray direction, must be normalized.

Calculates the intersection between a ray and a triangle. Returns None if there is no intersection.

static triNormal(v1, v2, v3) → Vector

Calculates a normal for a triangle.

Attributes

x - float
y - float
z - float

Numeric protocol

Most operations have in-place (v *= 2 etc.) versions.

class d3d11.Vector
Vector * float -> Vector

Float multiply.

Vector / float -> Vector

Float divide.

Vector + Vector -> Vector

Vector addition.

Vector - Vector -> Vector

Vector subtraction.

-Vector -> Vector

Negation v2 = -v.

Sequence protocol

Vector supports certain sequence operations for tuple-like behaviour.

class d3d11.Vector
Vector[int index] -> float

Returns the indexed value.

v = Vector(...)
assert (v.x == v[0] and v.y == v[1] and v.z == v[2])
len(Vector) → int

Sequence length of a vector is always 3.

Table Of Contents

Get DirectPython 11 at SourceForge.net. Fast, secure and Free Open Source software downloads