-
Notifications
You must be signed in to change notification settings - Fork 0
Home
shBLOCK edited this page Oct 4, 2023
·
11 revisions
Since the 6 vector classes are mostly similar, Vec3 is used in this part of the documentation, and methods specific to a class are particularized.
-
Vec3(x: float | int, y: float | int, z: float | int)
returnsVec3(x, y, z)
-
Vec3(value: float | int)
returnsVec3(value, value, value)
-
Vec3()
returns Vec3(0.0, 0.0, 0.0) -
Vec3(vec: Vec3)
returns a copy of that vector -
Vec3(vec: Vec3i)
converts Vec3i to Vec3 - Any combination of vectors and numbers that has 3 dimensions in total is also supported, however this doesn't include vector classes of a different data type.
Vec3(a: Vec2, b: float | int)
Vec3(a: float | int, b: Vec2)
-
x
y
z
-
length
the length of the vector -
length_sqr
the squared length of the vector -
normalized
the normalized vector - "Swizzling" is supported, so any combinations of
x
y
z
o
l
are properties of the vector.- These properties return a vector of the length of the property's name.
-
x
y
z
represents the components of this vector. -
o
represents zero andl
represents one. - Combinations consisting of only constants (
o
andl
) are not included. - Examples (Assume that
vec = Vec3(2, 3, 4)
):-
vec.xyz
givesVec3(4.0, 3.0, 2.0)
-
vec.zx
givesVec2(4.0, 2.0)
-
vec.xxxx
givesVec4(2.0, 2.0, 2.0, 2.0)
-
vec.xoly
givesVec4(2.0, 0.0, 1.0, 4.0)
-
We use a
and b
to represent vectors in this part.
a + b
a - b
-
a * b
multiplied each component ofa
andb
together -
a / b
divide each component ofa
byb
- For
+
-
*
and/
,b
can also be a number, in whichb
is treated asVec3(b)
-
+a
returns a copy ofa
-
-a
the inverse vector ofa
-
a == b
a != b
check for exact equality -
a.is_close(b, rel_tol=1e-5, abs_tol=1e-14)
check for equality with tolerance (similar tomath.isclose()
) -
bool(a)
returnsTrue
ifa
is NOT a zero vector,False
otherwise -
a @ b
the dot product ofa
andb
-
a ^ b
the cross product ofa
andb
(Only avaliable inVec3
andVec3i
) -
len(a)
returns the component count ofa
(NOT its length!!!) a.distance_to(b)
-
a.distance_sqr_to(b)
returns the squared distance betweena
andb
-
a | b
same asa.distance_to(b)
-
a[i]
a[i] = value
get and set thei
th component ofa
-
iter(a)
returns an internal iterator object
for component in Vec3(1, 2, 3):
print(component)
Prints: 1 2 and 3 (in different lines)
This part covers the common parts of all transform classes, see Transform2D
and Transform3D
for things specific to them.
TODO
TODO
TODO