Module Mathutils
[hide private]
[frames] | no frames]

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 - def reflect(mirror):
525 """ 526 Return the reflection vector from the mirror vector argument. 527 @type mirror: Vector object 528 @param mirror: This vector could be a normal from the reflecting surface. 529 @rtype: Vector object matching the size of this vector. 530 @return: The reflected vector. 531 """
532
533 -class Euler:
534 """ 535 The Euler object 536 ================ 537 This object gives access to Eulers in Blender. 538 @ivar x: The heading value in degrees. 539 @ivar y: The pitch value in degrees. 540 @ivar z: The roll value in degrees. 541 @ivar wrapped: Whether or not this object is wrapping data directly 542 @note: You can access a euler object like a sequence 543 - x = euler[0] 544 @note: Comparison operators can be done: 545 - ==, != test numeric values within epsilon 546 @attention: Euler data can be wrapped or non-wrapped. When a object is wrapped it 547 means that the object will give you direct access to the data inside of blender. Modification 548 of this object will directly change the data inside of blender. To copy a wrapped object 549 you need to use the object's constructor. If you copy and object by assignment you will not get 550 a second copy but a second reference to the same data. Only certain functions will return 551 wrapped data. This will be indicated in the method description. 552 Example:: 553 wrappedObject = Object.getAttribute() #this is wrapped data 554 print wrappedObject.wrapped #prints 'True' 555 copyOfObject = Object(wrappedObject) #creates a copy of the object 556 secondPointer = wrappedObject #creates a second pointer to the same data 557 print wrappedObject.attribute #prints '5' 558 secondPointer.attribute = 10 559 print wrappedObject.attribute #prints '10' 560 print copyOfObject.attribute #prints '5' 561 """ 562
563 - def __init__(list = None):
564 """ 565 Create a new euler object. 566 567 Example:: 568 euler = Euler(45,0,0) 569 euler = Euler(myEuler) 570 euler = Euler(sequence) 571 @type list: PyList of float/int 572 @param list: 3d list to initialize euler 573 @rtype: Euler object 574 @return: Euler representing heading, pitch, bank. 575 @note: Values are in degrees. 576 """
577
578 - def zero():
579 """ 580 Set all values to zero. 581 @return: an instance of itself 582 """
583
584 - def copy():
585 """ 586 @return: a copy of this euler. 587 """
588
589 - def unique():
590 """ 591 Calculate a unique rotation for this euler. Avoids gimble lock. 592 @return: an instance of itself 593 """
594
595 - def toMatrix():
596 """ 597 Return a matrix representation of the euler. 598 @rtype: Matrix object 599 @return: A roation matrix representation of the euler. 600 """
601
602 - def toQuat():
603 """ 604 Return a quaternion representation of the euler. 605 @rtype: Quaternion object 606 @return: Quaternion representation of the euler. 607 """
608
609 -class Quaternion:
610 """ 611 The Quaternion object 612 ===================== 613 This object gives access to Quaternions in Blender. 614 @ivar w: The w value. 615 @ivar x: The x value. 616 @ivar y: The y value. 617 @ivar z: The z value. 618 @ivar wrapped: Wether or not this object wraps data directly 619 @ivar magnitude: The magnitude of the quaternion. 620 @ivar axis: Vector representing the axis of rotation. 621 @ivar angle: A scalar representing the amount of rotation 622 in degrees. 623 @note: Comparison operators can be done: 624 - ==, != test numeric values within epsilon 625 @note: Math can be performed on Quaternion classes 626 - quat + quat 627 - quat - quat 628 - quat * float/int 629 - quat * vec 630 - quat * quat 631 @note: You can access a quaternion object like a sequence 632 - x = quat[0] 633 @attention: Quaternion data can be wrapped or non-wrapped. When a object is wrapped it 634 means that the object will give you direct access to the data inside of blender. Modification 635 of this object will directly change the data inside of blender. To copy a wrapped object 636 you need to use the object's constructor. If you copy and object by assignment you will not get 637 a second copy but a second reference to the same data. Only certain functions will return 638 wrapped data. This will be indicated in the method description. 639 Example:: 640 wrappedObject = Object.getAttribute() #this is wrapped data 641 print wrappedObject.wrapped #prints 'True' 642 copyOfObject = Object(wrappedObject) #creates a copy of the object 643 secondPointer = wrappedObject #creates a second pointer to the same data 644 print wrappedObject.attribute #prints '5' 645 secondPointer.attribute = 10 646 print wrappedObject.attribute #prints '10' 647 print copyOfObject.attribute #prints '5' 648 """ 649
650 - def __init__(list, angle = None):
651 """ 652 Create a new quaternion object from initialized values. 653 654 Example:: 655 quat = Quaternion(1,2,3,4) 656 quat = Quaternion(axis, angle) 657 quat = Quaternion() 658 quat = Quaternion(180, list) 659 660 @type list: PyList of int/float 661 @param list: A 3d or 4d list to initialize quaternion. 662 4d if intializing [w,x,y,z], 3d if used as an axis of rotation. 663 @type angle: float (optional) 664 @param angle: An arbitrary rotation amount around 'list'. 665 List is used as an axis of rotation in this case. 666 @rtype: New quaternion object. 667 @return: It depends wheter a parameter was passed: 668 - (list/angle): Quaternion object initialized with the given values; 669 - (): An identity 4 dimensional quaternion. 670 """
671
672 - def identity():
673 """ 674 Set the quaternion to the identity quaternion. 675 @return: an instance of itself 676 """
677
678 - def copy():
679 """ 680 make a copy of the quaternion. 681 @return: a copy of itself 682 """
683
684 - def negate():
685 """ 686 Set the quaternion to its negative. 687 @return: an instance of itself 688 """
689
690 - def conjugate():
691 """ 692 Set the quaternion to its conjugate. 693 @return: an instance of itself 694 """
695
696 - def inverse():
697 """ 698 Set the quaternion to its inverse 699 @return: an instance of itself 700 """
701
702 - def normalize():
703 """ 704 Normalize the quaternion. 705 @return: an instance of itself 706 """
707
708 - def toEuler():
709 """ 710 Return Euler representation of the quaternion. 711 @rtype: Euler object 712 @return: Euler representation of the quaternion. 713 """
714
715 - def toMatrix():
716 """ 717 Return a matrix representation of the quaternion. 718 @rtype: Matrix object 719 @return: A rotation matrix representation of the quaternion. 720 """
721
722 -class Matrix:
723 """ 724 The Matrix Object 725 ================= 726 This object gives access to Matrices in Blender. 727 @ivar rowSize: The row size of the matrix. 728 @ivar colSize: The column size of the matrix. 729 @ivar wrapped: Whether or not this object wrapps internal data 730 @note: Math can be performed on Matrix classes 731 - mat + mat 732 - mat - mat 733 - mat * float/int 734 - mat * vec 735 - mat * mat 736 @note: Comparison operators can be done: 737 - ==, != test numeric values within epsilon 738 @note: You can access a quaternion object like a 2d sequence 739 - x = matrix[0][1] 740 - vector = matrix[2] 741 @attention: Quaternion data can be wrapped or non-wrapped. When a object is wrapped it 742 means that the object will give you direct access to the data inside of blender. Modification 743 of this object will directly change the data inside of blender. To copy a wrapped object 744 you need to use the object's constructor. If you copy and object by assignment you will not get 745 a second copy but a second reference to the same data. Only certain functions will return 746 wrapped data. This will be indicated in the method description. 747 Example:: 748 wrappedObject = Object.getAttribute() #this is wrapped data 749 print wrappedObject.wrapped #prints 'True' 750 copyOfObject = Object(wrappedObject) #creates a copy of the object 751 secondPointer = wrappedObject #creates a second pointer to the same data 752 print wrappedObject.attribute #prints '5' 753 secondPointer.attribute = 10 754 print wrappedObject.attribute #prints '10' 755 print copyOfObject.attribute #prints '5' 756 """ 757
758 - def __init__(list1 = None, list2 = None, list3 = None, list4 = None):
759 """ 760 Create a new matrix object from initialized values. 761 762 Example:: 763 matrix = Matrix([1,1,1],[0,1,0],[1,0,0]) 764 matrix = Matrix(mat) 765 matrix = Matrix(seq1, seq2, vector) 766 767 @type list1: PyList of int/float 768 @param list1: A 2d,3d or 4d list. 769 @type list2: PyList of int/float 770 @param list2: A 2d,3d or 4d list. 771 @type list3: PyList of int/float 772 @param list3: A 2d,3d or 4d list. 773 @type list4: PyList of int/float 774 @param list4: A 2d,3d or 4d list. 775 @rtype: New matrix object. 776 @return: It depends wheter a parameter was passed: 777 - (list1, etc.): Matrix object initialized with the given values; 778 - (): An empty 3 dimensional matrix. 779 """
780
781 - def zero():
782 """ 783 Set all matrix values to 0. 784 @return: an instance of itself 785 """
786 787
788 - def copy():
789 """ 790 Returns a copy of this matrix 791 @return: a copy of itself 792 """
793
794 - def identity():
795 """ 796 Set the matrix to the identity matrix. 797 An object with zero location and rotation, a scale of 1, will have an identity matrix. 798 799 See U{http://en.wikipedia.org/wiki/Identity_matrix} 800 @return: an instance of itself 801 """
802
803 - def transpose():
804 """ 805 Set the matrix to its transpose. 806 807 See U{http://en.wikipedia.org/wiki/Transpose} 808 @return: None 809 """
810
811 - def determinant():
812 """ 813 Return the determinant of a matrix. 814 815 See U{http://en.wikipedia.org/wiki/Determinant} 816 @rtype: float 817 @return: Return a the determinant of a matrix. 818 """
819
820 - def invert():
821 """ 822 Set the matrix to its inverse. 823 824 See U{http://en.wikipedia.org/wiki/Inverse_matrix} 825 @return: an instance of itself. 826 @raise ValueError: When matrix is singular. 827 """
828
829 - def rotationPart():
830 """ 831 Return the 3d submatrix corresponding to the linear term of the 832 embedded affine transformation in 3d. This matrix represents rotation 833 and scale. Note that the (4,4) element of a matrix can be used for uniform 834 scaling, too. 835 @rtype: Matrix object. 836 @return: Return the 3d matrix for rotation and scale. 837 """
838
839 - def translationPart():
840 """ 841 Return a the translation part of a 4 row matrix. 842 @rtype: Vector object. 843 @return: Return a the translation of a matrix. 844 """
845
846 - def scalePart():
847 """ 848 Return a the scale part of a 3x3 or 4x4 matrix. 849 @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. 850 @rtype: Vector object. 851 @return: Return a the scale of a matrix. 852 """
853
854 - def resize4x4():
855 """ 856 Resize the matrix to by 4x4 857 @return: an instance of itself. 858 """
859
860 - def toEuler():
861 """ 862 Return an Euler representation of the rotation matrix (3x3 or 4x4 matrix only). 863 @rtype: Euler object 864 @return: Euler representation of the rotation matrix. 865 """
866
867 - def toQuat():
868 """ 869 Return a quaternion representation of the rotation matrix 870 @rtype: Quaternion object 871 @return: Quaternion representation of the rotation matrix 872 """
873