Module Mathutils

Source Code for Module Mathutils

  1  # Blender.Mathutils module and its subtypes 
  2   
  3  """ 
  4  The Blender.Mathutils submodule. 
  5   
  6  Mathutils 
  7  ========= 
  8   
  9  This module provides access to matrices, eulers, quaternions and vectors. 
 10   
 11  Example:: 
 12    import Blender 
 13    from Blender import Mathutils 
 14    from Blender.Mathutils import * 
 15   
 16    vec = Vector([1,2,3]) 
 17    mat = RotationMatrix(90, 4, 'x') 
 18    matT = TranslationMatrix(vec) 
 19   
 20    matTotal = mat * matT 
 21    matTotal.invert() 
 22   
 23    mat3 = matTotal.rotationPart 
 24    quat1 = mat.toQuat() 
 25    quat2 = mat3.toQuat() 
 26   
 27    angle = DifferenceQuats(quat1, quat2) 
 28    print angle   
 29  """ 
 30   
31 -def Rand (low=0.0, high = 1.0):
32 """ 33 Return a random number within a range. 34 low and high represent are optional parameters which represent the range 35 from which the random number must return its result. 36 @type low: float 37 @param low: The lower range. 38 @type high: float 39 @param high: The upper range. 40 """
41
42 -def Intersect(vec1, vec2, vec3, ray, orig, clip=1):
43 """ 44 Return the intersection between a ray and a triangle, if possible, return None otherwise. 45 @type vec1: Vector object. 46 @param vec1: A 3d vector, one corner of the triangle. 47 @type vec2: Vector object. 48 @param vec2: A 3d vector, one corner of the triangle. 49 @type vec3: Vector object. 50 @param vec3: A 3d vector, one corner of the triangle. 51 @type ray: Vector object. 52 @param ray: A 3d vector, the orientation of the ray. the length of the ray is not used, only the direction. 53 @type orig: Vector object. 54 @param orig: A 3d vector, the origin of the ray. 55 @type clip: integer 56 @param clip: if 0, don't restrict the intersection to the area of the triangle, use the infinite plane defined by the triangle. 57 @rtype: Vector object 58 @return: The intersection between a ray and a triangle, if possible, None otherwise. 59 """
60
61 -def TriangleArea(vec1, vec2, vec3):
62 """ 63 Return the area size of the 2D or 3D triangle defined. 64 @type vec1: Vector object. 65 @param vec1: A 2d or 3d vector, one corner of the triangle. 66 @type vec2: Vector object. 67 @param vec2: A 2d or 3d vector, one corner of the triangle. 68 @type vec3: Vector object. 69 @param vec3: A 2d or 3d vector, one corner of the triangle. 70 @rtype: float 71 @return: The area size of the 2D or 3D triangle defined. 72 """
73
74 -def TriangleNormal(vec1, vec2, vec3):
75 """ 76 Return the normal of the 3D triangle defined. 77 @type vec1: Vector object. 78 @param vec1: A 3d vector, one corner of the triangle. 79 @type vec2: Vector object. 80 @param vec2: A 3d vector, one corner of the triangle. 81 @type vec3: Vector object. 82 @param vec3: A 3d vector, one corner of the triangle. 83 @rtype: float 84 @return: The normal of the 3D triangle defined. 85 """
86
87 -def QuadNormal(vec1, vec2, vec3, vec4):
88 """ 89 Return the normal of the 3D quad defined. 90 @type vec1: Vector object. 91 @param vec1: A 3d vector, the first vertex of the quad. 92 @type vec2: Vector object. 93 @param vec2: A 3d vector, the second vertex of the quad. 94 @type vec3: Vector object. 95 @param vec3: A 3d vector, the third vertex of the quad. 96 @type vec4: Vector object. 97 @param vec4: A 3d vector, the fourth vertex of the quad. 98 @rtype: float 99 @return: The normal of the 3D quad defined. 100 """
101
102 -def LineIntersect(vec1, vec2, vec3, vec4):
103 """ 104 Return a tuple with the points on each line respectively closest to the other 105 (when both lines intersect, both vector hold the same value). 106 The lines are evaluated as infinite lines in space, the values returned may not be between the 2 points given for each line. 107 @type vec1: Vector object. 108 @param vec1: A 3d vector, one point on the first line. 109 @type vec2: Vector object. 110 @param vec2: A 3d vector, another point on the first line. 111 @type vec3: Vector object. 112 @param vec3: A 3d vector, one point on the second line. 113 @type vec4: Vector object. 114 @param vec4: A 3d vector, another point on the second line. 115 @rtype: (Vector object, Vector object) 116 @return: A tuple with the points on each line respectively closest to the other. 117 """
118
119 -def CopyVec(vector):
120 """ 121 Create a copy of the Vector object. 122 @attention: B{DEPRECATED} use vector.copy() instead. 123 @type vector: Vector object. 124 @param vector: A 2d,3d or 4d vector to be copied. 125 @rtype: Vector object. 126 @return: A new vector object which is a copy of the one passed in. 127 """
128
129 -def CrossVecs(vec1, vec2):
130 """ 131 Return the cross product of two vectors. 132 @type vec1: Vector object. 133 @param vec1: A 3d vector. 134 @type vec2: Vector object. 135 @param vec2: A 3d vector. 136 @rtype: Vector object. 137 @return: A new vector representing the cross product of 138 the two vectors. 139 """
140
141 -def DotVecs(vec1, vec2):
142 """ 143 Return the dot product of two vectors. 144 @type vec1: Vector object. 145 @param vec1: A 2d,3d or 4d vector. 146 @type vec2: Vector object. 147 @param vec2: A 2d,3d or 4d vector. 148 @rtype: float 149 @return: Return the scalar product of vector muliplication. 150 """
151
152 -def AngleBetweenVecs(vec1, vec2):
153 """ 154 Return the angle between two vectors. Zero length vectors raise an error. 155 @type vec1: Vector object. 156 @param vec1: A 2d or 3d vector. 157 @type vec2: Vector object. 158 @param vec2: A 2d or 3d vector. 159 @rtype: float 160 @return: The angle between the vectors in degrees. 161 @raise AttributeError: When there is a zero-length vector as an argument. 162 """
163
164 -def MidpointVecs(vec1, vec2):
165 """ 166 Return a vector to the midpoint between two vectors. 167 @type vec1: Vector object. 168 @param vec1: A 2d,3d or 4d vector. 169 @type vec2: Vector object. 170 @param vec2: A 2d,3d or 4d vector. 171 @rtype: Vector object 172 @return: The vector to the midpoint. 173 """
174
175 -def VecMultMat(vec, mat):
176 """ 177 Multiply a vector and matrix (pre-multiply) 178 Vector size and matrix column size must equal. 179 @type vec: Vector object. 180 @param vec: A 2d,3d or 4d vector. 181 @type mat: Matrix object. 182 @param mat: A 2d,3d or 4d matrix. 183 @rtype: Vector object 184 @return: The row vector that results from the muliplication. 185 @attention: B{DEPRECATED} You should now multiply vector * matrix direcly 186 Example:: 187 result = myVector * myMatrix 188 """
189
190 -def ProjectVecs(vec1, vec2):
191 """ 192 Return the projection of vec1 onto vec2. 193 @type vec1: Vector object. 194 @param vec1: A 2d,3d or 4d vector. 195 @type vec2: Vector object. 196 @param vec2: A 2d,3d or 4d vector. 197 @rtype: Vector object 198 @return: The parallel projection vector. 199 """
200
201 -def RotationMatrix(angle, matSize, axisFlag, axis):
202 """ 203 Create a matrix representing a rotation. 204 @type angle: float 205 @param angle: The angle of rotation desired. 206 @type matSize: int 207 @param matSize: The size of the rotation matrix to construct. 208 Can be 2d, 3d, or 4d. 209 @type axisFlag: string (optional) 210 @param axisFlag: Possible values: 211 - "x - x-axis rotation" 212 - "y - y-axis rotation" 213 - "z - z-axis rotation" 214 - "r - arbitrary rotation around vector" 215 @type axis: Vector object. (optional) 216 @param axis: The arbitrary axis of rotation used with "R" 217 @rtype: Matrix object. 218 @return: A new rotation matrix. 219 """
220
221 -def TranslationMatrix(vector):
222 """ 223 Create a matrix representing a translation 224 @type vector: Vector object 225 @param vector: The translation vector 226 @rtype: Matrix object. 227 @return: An identity matrix with a translation. 228 """
229
230 -def ScaleMatrix(factor, matSize, axis):
231 """ 232 Create a matrix representing a scaling. 233 @type factor: float 234 @param factor: The factor of scaling to apply. 235 @type matSize: int 236 @param matSize: The size of the scale matrix to construct. 237 Can be 2d, 3d, or 4d. 238 @type axis: Vector object. (optional) 239 @param axis: Direction to influence scale. 240 @rtype: Matrix object. 241 @return: A new scale matrix. 242 """
243
244 -def OrthoProjectionMatrix(plane, matSize, axis):
245 """ 246 Create a matrix to represent an orthographic projection 247 @type plane: string 248 @param plane: Can be any of the following: 249 - "x - x projection (2D)" 250 - "y - y projection (2D)" 251 - "xy - xy projection" 252 - "xz - xz projection" 253 - "yz - yz projection" 254 - "r - arbitrary projection plane" 255 @type matSize: int 256 @param matSize: The size of the projection matrix to construct. 257 Can be 2d, 3d, or 4d. 258 @type axis: Vector object. (optional) 259 @param axis: Arbitrary perpendicular plane vector. 260 @rtype: Matrix object. 261 @return: A new projeciton matrix. 262 """
263
264 -def ShearMatrix(plane, factor, matSize):
265 """ 266 Create a matrix to represent an orthographic projection 267 @type plane: string 268 @param plane: Can be any of the following: 269 - "x - x shear (2D)" 270 - "y - y shear (2D)" 271 - "xy - xy shear" 272 - "xz - xz shear" 273 - "yz - yz shear" 274 @type factor: float 275 @param factor: The factor of shear to apply. 276 @type matSize: int 277 @param matSize: The size of the projection matrix to construct. 278 Can be 2d, 3d, or 4d. 279 @rtype: Matrix object. 280 @return: A new shear matrix. 281 """
282
283 -def CopyMat(matrix):
284 """ 285 Create a copy of the Matrix object. 286 @type matrix: Matrix object. 287 @param matrix: A 2d,3d or 4d matrix to be copied. 288 @rtype: Matrix object. 289 @return: A new matrix object which is a copy of the one passed in. 290 @attention: B{DEPRECATED} Use the matrix copy funtion to make a copy. 291 Example:: 292 newMat = myMat.copy() 293 """
294
295 -def MatMultVec(mat, vec):
296 """ 297 Multiply a matrix and a vector (post-multiply) 298 Vector size and matrix row size must equal. 299 @type vec: Vector object. 300 @param vec: A 2d,3d or 4d vector. 301 @type mat: Matrix object. 302 @param mat: A 2d,3d or 4d matrix. 303 @rtype: Vector object 304 @return: The column vector that results from the muliplication. 305 @attention: B{DEPRECATED} You should use direct muliplication on the arguments 306 Example:: 307 result = myMatrix * myVector 308 """
309
310 -def CopyQuat(quaternion):
311 """ 312 Create a copy of the Quaternion object. 313 @type quaternion: Quaternion object. 314 @param quaternion: Quaternion to be copied. 315 @rtype: Quaternion object. 316 @return: A new quaternion object which is a copy of the one passed in. 317 @attention: B{DEPRECATED} You should use the Quaterion() constructor directly 318 to create copies of quaternions 319 Example:: 320 newQuat = Quaternion(myQuat) 321 """
322
323 -def CrossQuats(quat1, quat2):
324 """ 325 Return the cross product of two quaternions. 326 @type quat1: Quaternion object. 327 @param quat1: Quaternion. 328 @type quat2: Quaternion object. 329 @param quat2: Quaternion. 330 @rtype: Quaternion object. 331 @return: A new quaternion representing the cross product of 332 the two quaternions. 333 """
334
335 -def DotQuats(quat1, quat2):
336 """ 337 Return the dot product of two quaternions. 338 @type quat1: Quaternion object. 339 @param quat1: Quaternion. 340 @type quat2: Quaternion object. 341 @param quat2: Quaternion. 342 @rtype: float 343 @return: Return the scalar product of quaternion muliplication. 344 """
345
346 -def DifferenceQuats(quat1, quat2):
347 """ 348 Returns a quaternion represting the rotational difference. 349 @type quat1: Quaternion object. 350 @param quat1: Quaternion. 351 @type quat2: Quaternion object. 352 @param quat2: Quaternion. 353 @rtype: Quaternion object 354 @return: Return a quaternion which which represents the rotational 355 difference between the two quat rotations. 356 """
357
358 -def Slerp(quat1, quat2, factor):
359 """ 360 Returns the interpolation of two quaternions. 361 @type quat1: Quaternion object. 362 @param quat1: Quaternion. 363 @type quat2: Quaternion object. 364 @param quat2: Quaternion. 365 @type factor: float 366 @param factor: The interpolation value 367 @rtype: Quaternion object 368 @return: The interpolated rotation. 369 """
370
371 -def CopyEuler(euler):
372 """ 373 Create a new euler object. 374 @type euler: Euler object 375 @param euler: The euler to copy 376 @rtype: Euler object 377 @return: A copy of the euler object passed in. 378 @attention: B{DEPRECATED} You should use the Euler constructor directly 379 to make copies of Euler objects 380 Example:: 381 newEuler = Euler(myEuler) 382 """
383
384 -def RotateEuler(euler, angle, axis):
385 """ 386 Roatate a euler by an amount in degrees around an axis. 387 @type euler: Euler object 388 @param euler: Euler to rotate. 389 @type angle: float 390 @param angle: The amount of rotation in degrees 391 @type axis: string 392 @param axis: axis to rotate around: 393 - "x" 394 - "y" 395 - "z" 396 """
397
398 -class Vector:
399 """ 400 The Vector object 401 ================= 402 This object gives access to Vectors in Blender. 403 @ivar x: The x value. 404 @ivar y: The y value. 405 @ivar z: The z value (if any). 406 @ivar w: The w value (if any). 407 @ivar length: The magnitude of the vector. 408 @ivar magnitude: This is a synonym for length. 409 @ivar wrapped: Whether or not this item is wrapped data 410 @note: Comparison operators can be done on Vector classes: 411 - >, >=, <, <= test the vector magnitude 412 - ==, != test vector values e.g. 1,2,3 != 1,2,4 even if they are the same length 413 @note: Math can be performed on Vector classes 414 - vec + vec 415 - vec - vec 416 - vec * float/int 417 - vec * matrix 418 - vec * vec 419 - vec * quat 420 - -vec 421 @note: You can access a vector object like a sequence 422 - x = vector[0] 423 @attention: Vector data can be wrapped or non-wrapped. When a object is wrapped it 424 means that the object will give you direct access to the data inside of blender. Modification 425 of this object will directly change the data inside of blender. To copy a wrapped object 426 you need to use the object's constructor. If you copy and object by assignment you will not get 427 a second copy but a second reference to the same data. Only certain functions will return 428 wrapped data. This will be indicated in the method description. 429 Example:: 430 wrappedObject = Object.getAttribute() #this is wrapped data 431 print wrappedObject.wrapped #prints 'True' 432 copyOfObject = Object(wrappedObject) #creates a copy of the object 433 secondPointer = wrappedObject #creates a second pointer to the same data 434 print wrappedObject.attribute #prints '5' 435 secondPointer.attribute = 10 436 print wrappedObject.attribute #prints '10' 437 print copyOfObject.attribute #prints '5' 438 """ 439
440 - def __init__(list = None):
441 """ 442 Create a new 2d, 3d, or 4d Vector object from a list of floating point numbers. 443 @note: that python uses higher precission floating point numbers, so values assigned to a vector may have some rounding error. 444 445 446 Example:: 447 v = Vector(1,0,0) 448 v = Vector(myVec) 449 v = Vector(list) 450 @type list: PyList of float or int 451 @param list: The list of values for the Vector object. Can be a sequence or raw numbers. 452 Must be 2, 3, or 4 values. The list is mapped to the parameters as [x,y,z,w]. 453 @rtype: Vector object. 454 @return: It depends wheter a parameter was passed: 455 - (list): Vector object initialized with the given values; 456 - (): An empty 3 dimensional vector. 457 """
458
459 - def copy():
460 """ 461 Returns a copy of this vector 462 @return: a copy of itself 463 """
464
465 - def zero():
466 """ 467 Set all values to zero. 468 @return: an instance of itself 469 """
470
471 - def normalize():
472 """ 473 Normalize the vector, making the length of the vector always 1.0 474 @note: Normalize works for vectors of all sizes, however 4D Vectors w axis is left untouched. 475 @note: Normalizing a vector where all values are zero results in all axis having a nan value (not a number). 476 @return: an instance of itself 477 """
478
479 - def negate():
480 """ 481 Set all values to their negative. 482 @return: an instance of its self 483 """
484
485 - def resize2D():
486 """ 487 Resize the vector to 2d. 488 @return: an instance of itself 489 """
490
491 - def resize3D():
492 """ 493 Resize the vector to 3d. New axis will be 0.0. 494 @return: an instance of itself 495 """
496
497 - def resize4D():
498 """ 499 Resize the vector to 4d. New axis will be 0.0. 500 The last component will be 1.0, to make multiplying 3d vectors by 4x4 matrices easier. 501 @return: an instance of itself 502 """
503
504 - def toTrackQuat(track, up):
505 """ 506 Return a quaternion rotation from the vector and the track and up axis. 507 @type track: String. 508 @param track: Possible values: 509 - "x - x-axis up" 510 - "y - y-axis up" 511 - "z - z-axis up" 512 - "-x - negative x-axis up" 513 - "-y - negative y-axis up" 514 - "-z - negative z-axis up" 515 @type up: String. 516 @param up: Possible values: 517 - "x - x-axis up" 518 - "y - y-axis up" 519 - "z - z-axis up" 520 @rtype: Quaternion 521 @return: Return a quaternion rotation from the vector and the track and up axis. 522 """
523
524 -class Euler:
525 """ 526 The Euler object 527 ================ 528 This object gives access to Eulers in Blender. 529 @ivar x: The heading value in degrees. 530 @ivar y: The pitch value in degrees. 531 @ivar z: The roll value in degrees. 532 @ivar wrapped: Whether or not this object is wrapping data directly 533 @note: You can access a euler object like a sequence 534 - x = euler[0] 535 @note: Comparison operators can be done: 536 - ==, != test numeric values within epsilon 537 @attention: Euler data can be wrapped or non-wrapped. When a object is wrapped it 538 means that the object will give you direct access to the data inside of blender. Modification 539 of this object will directly change the data inside of blender. To copy a wrapped object 540 you need to use the object's constructor. If you copy and object by assignment you will not get 541 a second copy but a second reference to the same data. Only certain functions will return 542 wrapped data. This will be indicated in the method description. 543 Example:: 544 wrappedObject = Object.getAttribute() #this is wrapped data 545 print wrappedObject.wrapped #prints 'True' 546 copyOfObject = Object(wrappedObject) #creates a copy of the object 547 secondPointer = wrappedObject #creates a second pointer to the same data 548 print wrappedObject.attribute #prints '5' 549 secondPointer.attribute = 10 550 print wrappedObject.attribute #prints '10' 551 print copyOfObject.attribute #prints '5' 552 """ 553
554 - def __init__(list = None):
555 """ 556 Create a new euler object. 557 558 Example:: 559 euler = Euler(45,0,0) 560 euler = Euler(myEuler) 561 euler = Euler(sequence) 562 @type list: PyList of float/int 563 @param list: 3d list to initialize euler 564 @rtype: Euler object 565 @return: Euler representing heading, pitch, bank. 566 @note: Values are in degrees. 567 """
568
569 - def zero():
570 """ 571 Set all values to zero. 572 @return: an instance of itself 573 """
574
575 - def copy():
576 """ 577 @return: a copy of this euler. 578 """
579
580 - def unique():
581 """ 582 Calculate a unique rotation for this euler. Avoids gimble lock. 583 @return: an instance of itself 584 """
585
586 - def toMatrix():
587 """ 588 Return a matrix representation of the euler. 589 @rtype: Matrix object 590 @return: A roation matrix representation of the euler. 591 """
592
593 - def toQuat():
594 """ 595 Return a quaternion representation of the euler. 596 @rtype: Quaternion object 597 @return: Quaternion representation of the euler. 598 """
599
600 -class Quaternion:
601 """ 602 The Quaternion object 603 ===================== 604 This object gives access to Quaternions in Blender. 605 @ivar w: The w value. 606 @ivar x: The x value. 607 @ivar y: The y value. 608 @ivar z: The z value. 609 @ivar wrapped: Wether or not this object wraps data directly 610 @ivar magnitude: The magnitude of the quaternion. 611 @ivar axis: Vector representing the axis of rotation. 612 @ivar angle: A scalar representing the amount of rotation 613 in degrees. 614 @note: Comparison operators can be done: 615 - ==, != test numeric values within epsilon 616 @note: Math can be performed on Quaternion classes 617 - quat + quat 618 - quat - quat 619 - quat * float/int 620 - quat * vec 621 - quat * quat 622 @note: You can access a quaternion object like a sequence 623 - x = quat[0] 624 @attention: Quaternion data can be wrapped or non-wrapped. When a object is wrapped it 625 means that the object will give you direct access to the data inside of blender. Modification 626 of this object will directly change the data inside of blender. To copy a wrapped object 627 you need to use the object's constructor. If you copy and object by assignment you will not get 628 a second copy but a second reference to the same data. Only certain functions will return 629 wrapped data. This will be indicated in the method description. 630 Example:: 631 wrappedObject = Object.getAttribute() #this is wrapped data 632 print wrappedObject.wrapped #prints 'True' 633 copyOfObject = Object(wrappedObject) #creates a copy of the object 634 secondPointer = wrappedObject #creates a second pointer to the same data 635 print wrappedObject.attribute #prints '5' 636 secondPointer.attribute = 10 637 print wrappedObject.attribute #prints '10' 638 print copyOfObject.attribute #prints '5' 639 """ 640
641 - def __init__(list, angle = None):
642 """ 643 Create a new quaternion object from initialized values. 644 645 Example:: 646 quat = Quaternion(1,2,3,4) 647 quat = Quaternion(axis, angle) 648 quat = Quaternion() 649 quat = Quaternion(180, list) 650 651 @type list: PyList of int/float 652 @param list: A 3d or 4d list to initialize quaternion. 653 4d if intializing [w,x,y,z], 3d if used as an axis of rotation. 654 @type angle: float (optional) 655 @param angle: An arbitrary rotation amount around 'list'. 656 List is used as an axis of rotation in this case. 657 @rtype: New quaternion object. 658 @return: It depends wheter a parameter was passed: 659 - (list/angle): Quaternion object initialized with the given values; 660 - (): An identity 4 dimensional quaternion. 661 """
662
663 - def identity():
664 """ 665 Set the quaternion to the identity quaternion. 666 @return: an instance of itself 667 """
668
669 - def copy():
670 """ 671 make a copy of the quaternion. 672 @return: a copy of itself 673 """
674
675 - def negate():
676 """ 677 Set the quaternion to its negative. 678 @return: an instance of itself 679 """
680
681 - def conjugate():
682 """ 683 Set the quaternion to its conjugate. 684 @return: an instance of itself 685 """
686
687 - def inverse():
688 """ 689 Set the quaternion to its inverse 690 @return: an instance of itself 691 """
692
693 - def normalize():
694 """ 695 Normalize the quaternion. 696 @return: an instance of itself 697 """
698
699 - def toEuler():
700 """ 701 Return Euler representation of the quaternion. 702 @rtype: Euler object 703 @return: Euler representation of the quaternion. 704 """
705
706 - def toMatrix():
707 """ 708 Return a matrix representation of the quaternion. 709 @rtype: Matrix object 710 @return: A rotation matrix representation of the quaternion. 711 """
712
713 -class Matrix:
714 """ 715 The Matrix Object 716 ================= 717 This object gives access to Matrices in Blender. 718 @ivar rowSize: The row size of the matrix. 719 @ivar colSize: The column size of the matrix. 720 @ivar wrapped: Whether or not this object wrapps internal data 721 @note: Math can be performed on Matrix classes 722 - mat + mat 723 - mat - mat 724 - mat * float/int 725 - mat * vec 726 - mat * mat 727 @note: Comparison operators can be done: 728 - ==, != test numeric values within epsilon 729 @note: You can access a quaternion object like a 2d sequence 730 - x = matrix[0][1] 731 - vector = matrix[2] 732 @attention: Quaternion data can be wrapped or non-wrapped. When a object is wrapped it 733 means that the object will give you direct access to the data inside of blender. Modification 734 of this object will directly change the data inside of blender. To copy a wrapped object 735 you need to use the object's constructor. If you copy and object by assignment you will not get 736 a second copy but a second reference to the same data. Only certain functions will return 737 wrapped data. This will be indicated in the method description. 738 Example:: 739 wrappedObject = Object.getAttribute() #this is wrapped data 740 print wrappedObject.wrapped #prints 'True' 741 copyOfObject = Object(wrappedObject) #creates a copy of the object 742 secondPointer = wrappedObject #creates a second pointer to the same data 743 print wrappedObject.attribute #prints '5' 744 secondPointer.attribute = 10 745 print wrappedObject.attribute #prints '10' 746 print copyOfObject.attribute #prints '5' 747 """ 748
749 - def __init__(list1 = None, list2 = None, list3 = None, list4 = None):
750 """ 751 Create a new matrix object from initialized values. 752 753 Example:: 754 matrix = Matrix([1,1,1],[0,1,0],[1,0,0]) 755 matrix = Matrix(mat) 756 matrix = Matrix(seq1, seq2, vector) 757 758 @type list1: PyList of int/float 759 @param list1: A 2d,3d or 4d list. 760 @type list2: PyList of int/float 761 @param list2: A 2d,3d or 4d list. 762 @type list3: PyList of int/float 763 @param list3: A 2d,3d or 4d list. 764 @type list4: PyList of int/float 765 @param list4: A 2d,3d or 4d list. 766 @rtype: New matrix object. 767 @return: It depends wheter a parameter was passed: 768 - (list1, etc.): Matrix object initialized with the given values; 769 - (): An empty 3 dimensional matrix. 770 """
771
772 - def zero():
773 """ 774 Set all matrix values to 0. 775 @return: an instance of itself 776 """
777 778
779 - def copy():
780 """ 781 Returns a copy of this matrix 782 @return: a copy of itself 783 """
784
785 - def identity():
786 """ 787 Set the matrix to the identity matrix. 788 An object with zero location and rotation, a scale of 1, will have an identity matrix. 789 790 See U{http://en.wikipedia.org/wiki/Identity_matrix} 791 @return: an instance of itself 792 """
793
794 - def transpose():
795 """ 796 Set the matrix to its transpose. 797 798 See U{http://en.wikipedia.org/wiki/Transpose} 799 @return: None 800 """
801
802 - def determinant():
803 """ 804 Return the determinant of a matrix. 805 806 See U{http://en.wikipedia.org/wiki/Determinant} 807 @rtype: float 808 @return: Return a the determinant of a matrix. 809 """
810
811 - def invert():
812 """ 813 Set the matrix to its inverse. 814 815 See U{http://en.wikipedia.org/wiki/Inverse_matrix} 816 @return: an instance of itself. 817 @raise ValueError: When matrix is singular. 818 """
819
820 - def rotationPart():
821 """ 822 Return the 3d submatrix corresponding to the linear term of the 823 embedded affine transformation in 3d. This matrix represents rotation 824 and scale. Note that the (4,4) element of a matrix can be used for uniform 825 scaling, too. 826 @rtype: Matrix object. 827 @return: Return the 3d matrix for rotation and scale. 828 """
829
830 - def translationPart():
831 """ 832 Return a the translation part of a 4 row matrix. 833 @rtype: Vector object. 834 @return: Return a the translation of a matrix. 835 """
836
837 - def scalePart():
838 """ 839 Return a the scale part of a 3x3 or 4x4 matrix. 840 @note: This method does not return negative a scale on any axis because it is not possible to obtain this data from the matrix alone. 841 @rtype: Vector object. 842 @return: Return a the scale of a matrix. 843 """
844
845 - def resize4x4():
846 """ 847 Resize the matrix to by 4x4 848 @return: an instance of itself. 849 """
850
851 - def toEuler():
852 """ 853 Return an Euler representation of the rotation matrix (3x3 or 4x4 matrix only). 854 @rtype: Euler object 855 @return: Euler representation of the rotation matrix. 856 """
857
858 - def toQuat():
859 """ 860 Return a quaternion representation of the rotation matrix 861 @rtype: Quaternion object 862 @return: Quaternion representation of the rotation matrix 863 """
864