Lines Matching refs:self
33 def __init__(self, name, description, children):
34 self.name = name
35 self.description = description
36 self.children = children
39 def __init__(self):
144 def __init__(self):
147 def uniformVec4(self, count, mn, mx):
154 def uniformBVec4(self, count):
160 # def uniform(self,
229 def __init__(self, x):
230 self.x = x
232 def applyUnary(self, func): return Scalar(func(self.x))
233 def applyBinary(self, func, other): return Scalar(func(self.x, other.x))
235 def isEqual(self, other): assert isinstance(other, Scalar); return (self.x == other.x)
237 def expandVec(self, val): return val
238 def toScalar(self): return Scalar(self.x)
239 def toVec2(self): return Vec2(self.x, self.x)
240 def toVec3(self): return Vec3(self.x, self.x, self.x)
241 def toVec4(self): return Vec4(self.x, self.x, self.x, self.x)
242 def toUVec2(self): return UVec2(self.x, self.x)
243 def toUVec3(self): return UVec3(self.x, self.x, self.x)
244 def toUVec4(self): return UVec4(self.x, self.x, self.x, self.x)
245 def toMat2(self): return Mat.fromScalar(2, 2, float(self.x))
246 def toMat2x3(self): return Mat.fromScalar(2, 3, float(self.x))
247 def toMat2x4(self): return Mat.fromScalar(2, 4, float(self.x))
248 def toMat3x2(self): return Mat.fromScalar(3, 2, float(self.x))
249 def toMat3(self): return Mat.fromScalar(3, 3, float(self.x))
250 def toMat3x4(self): return Mat.fromScalar(3, 4, float(self.x))
251 def toMat4x2(self): return Mat.fromScalar(4, 2, float(self.x))
252 def toMat4x3(self): return Mat.fromScalar(4, 3, float(self.x))
253 def toMat4(self): return Mat.fromScalar(4, 4, float(self.x))
255 def toFloat(self): return Scalar(float(self.x))
256 def toInt(self): return Scalar(int(self.x))
257 def toUint(self): return Uint(int(self.x))
258 def toBool(self): return Scalar(bool(self.x))
260 def getNumScalars(self): return 1
261 def getScalars(self): return [self.x]
263 def typeString(self):
264 if isinstance(self.x, bool):
266 elif isinstance(self.x, int):
268 elif isinstance(self.x, float):
273 def vec4Swizzle(self):
276 def __str__(self):
277 return str(self.x).lower()
279 def __float__(self):
280 return float(self.x)
282 def length(self):
283 return Scalar(abs(self.x))
285 def distance(self, v):
287 return Scalar(abs(self.x - v.x))
289 def dot(self, v):
291 return Scalar(self.x * v.x)
293 def normalize(self):
294 return Scalar(glslSign(self.x))
296 def abs(self):
297 if isinstance(self.x, bool):
298 return Scalar(self.x)
300 return Scalar(abs(self.x))
302 def __neg__(self):
303 return Scalar(-self.x)
305 def __add__(self, val):
307 return Scalar(self.x + val.x)
309 def __sub__(self, val):
310 return self + (-val)
312 def __mul__(self, val):
314 return Scalar(self.x * val.x)
316 return Vec2(self.x * val.x, self.x * val.y)
318 return Vec3(self.x * val.x, self.x * val.y, self.x * val.z)
320 return Vec4(self.x * val.x, self.x * val.y, self.x * val.z, self.x * val.w)
324 def __div__(self, val):
326 return Scalar(self.x / val.x)
328 return Vec2(self.x / val.x, self.x / val.y)
330 return Vec3(self.x / val.x, self.x / val.y, self.x / val.z)
332 return Vec4(self.x / val.x, self.x / val.y, self.x / val.z, self.x / val.w)
337 def __init__(self, x):
339 self.x = x
341 def typeString(self):
344 def abs(self):
345 return Scalar.abs(self).toUint()
347 def __neg__(self):
348 return Scalar.__neg__(self).toUint()
350 def __add__(self, val):
351 return Scalar.__add__(self, val).toUint()
353 def __sub__(self, val):
354 return self + (-val)
356 def __mul__(self, val):
357 return Scalar.__mul__(self, val).toUint()
359 def __div__(self, val):
360 return Scalar.__div__(self, val).toUint()
371 def isEqual(self, other):
373 return (self.getScalars() == other.getScalars())
375 def length(self):
376 return Scalar(math.sqrt(self.dot(self).x))
378 def normalize(self):
379 return self * Scalar(1.0 / self.length().x)
381 def swizzle(self, indexList):
382 inScalars = self.getScalars()
386 def __init__(self):
389 def __eq__(self, other):
390 return self.isEqual(other)
392 def __ne__(self, other):
393 return not self.isEqual(other)
396 def __init__(self, x, y):
398 self.x = x
399 self.y = y
401 def applyUnary(self, func): return Vec2(func(self.x), func(self.y))
402 def applyBinary(self, func, other): return Vec2(func(self.x, other.x), func(self.y, other.y))
404 def expandVec(self, val): return val.toVec2()
405 def toScalar(self): return Scalar(self.x)
406 def toVec2(self): return Vec2(self.x, self.y)
407 def toVec3(self): return Vec3(self.x, self.y, 0.0)
408 def toVec4(self): return Vec4(self.x, self.y, 0.0, 0.0)
409 def toUVec2(self): return UVec2(self.x, self.y)
410 def toUVec3(self): return UVec3(self.x, self.y, 0.0)
411 def toUVec4(self): return UVec4(self.x, self.y, 0.0, 0.0)
412 def toMat2(self): return Mat2(float(self.x), 0.0, 0.0, float(self.y));
414 def toFloat(self): return Vec2(float(self.x), float(self.y))
415 def toInt(self): return Vec2(int(self.x), int(self.y))
416 def toUint(self): return UVec2(int(self.x), int(self.y))
417 def toBool(self): return Vec2(bool(self.x), bool(self.y))
419 def getNumScalars(self): return 2
420 def getScalars(self): return [self.x, self.y]
422 def typeString(self):
423 if isinstance(self.x, bool):
425 elif isinstance(self.x, int):
427 elif isinstance(self.x, float):
432 def vec4Swizzle(self):
435 def __str__(self):
436 if isinstance(self.x, bool):
437 return "bvec2(%s, %s)" % (str(self.x).lower(), str(self.y).lower())
438 elif isinstance(self.x, int):
439 return "ivec2(%i, %i)" % (self.x, self.y)
440 elif isinstance(self.x, float):
441 return "vec2(%s, %s)" % (self.x, self.y)
445 def distance(self, v):
447 return (self - v).length()
449 def dot(self, v):
451 return Scalar(self.x*v.x + self.y*v.y)
453 def abs(self):
454 if isinstance(self.x, bool):
455 return Vec2(self.x, self.y)
457 return Vec2(abs(self.x), abs(self.y))
459 def __neg__(self):
460 return Vec2(-self.x, -self.y)
462 def __add__(self, val):
464 return Vec2(self.x + val, self.y + val)
466 return Vec2(self.x + val.x, self.y + val.y)
470 def __sub__(self, val):
471 return self + (-val)
473 def __mul__(self, val):
477 return Vec2(self.x * val.x, self.y * val.y)
479 def __div__(self, val):
481 return Vec2(self.x / val.x, self.y / val.x)
484 return Vec2(self.x / val.x, self.y / val.y)
486 def boolAny(self): return Scalar(self.x or self.y)
487 def boolAll(self): return Scalar(self.x and self.y)
488 def boolNot(self): return Vec2(not self.x, not self.y)
491 def __init__(self, x, y):
494 Vec2.__init__(self, x, y)
496 def typeString(self):
499 def __str__(self):
500 return "uvec2(%i, %i)" % (self.x, self.y)
502 def abs(self):
503 return Vec2.abs(self).toUint()
506 def __init__(self, x, y, z):
508 self.x = x
509 self.y = y
510 self.z = z
512 def applyUnary(self, func): return Vec3(func(self.x), func(self.y), func(self.z))
513 def applyBinary(self, func, other): return Vec3(func(self.x, other.x), func(self.y, other.y), func(self.z, other.z))
515 def expandVec(self, val): return val.toVec3()
516 def toScalar(self): return Scalar(self.x)
517 def toVec2(self): return Vec2(self.x, self.y)
518 def toVec3(self): return Vec3(self.x, self.y, self.z)
519 def toVec4(self): return Vec4(self.x, self.y, self.z, 0.0)
520 def toUVec2(self): return UVec2(self.x, self.y)
521 def toUVec3(self): return UVec3(self.x, self.y, self.z)
522 def toUVec4(self): return UVec4(self.x, self.y, self.z, 0.0)
523 def toMat3(self): return Mat3(float(self.x), 0.0, 0.0, 0.0, float(self.y), 0.0, 0.0, 0.0, float(self.z));
525 def toFloat(self): return Vec3(float(self.x), float(self.y), float(self.z))
526 def toInt(self): return Vec3(int(self.x), int(self.y), int(self.z))
527 def toUint(self): return UVec3(int(self.x), int(self.y), int(self.z))
528 def toBool(self): return Vec3(bool(self.x), bool(self.y), bool(self.z))
530 def getNumScalars(self): return 3
531 def getScalars(self): return [self.x, self.y, self.z]
533 def typeString(self):
534 if isinstance(self.x, bool):
536 elif isinstance(self.x, int):
538 elif isinstance(self.x, float):
543 def vec4Swizzle(self):
546 def __str__(self):
547 if isinstance(self.x, bool):
548 return "bvec3(%s, %s, %s)" % (str(self.x).lower(), str(self.y).lower(), str(self.z).lower())
549 elif isinstance(self.x, int):
550 return "ivec3(%i, %i, %i)" % (self.x, self.y, self.z)
551 elif isinstance(self.x, float):
552 return "vec3(%s, %s, %s)" % (self.x, self.y, self.z)
556 def distance(self, v):
558 return (self - v).length()
560 def dot(self, v):
562 return Scalar(self.x*v.x + self.y*v.y + self.z*v.z)
564 def cross(self, v):
566 return Vec3(self.y*v.z - v.y*self.z,
567 self.z*v.x - v.z*self.x,
568 self.x*v.y - v.x*self.y)
570 def abs(self):
571 if isinstance(self.x, bool):
572 return Vec3(self.x, self.y, self.z)
574 return Vec3(abs(self.x), abs(self.y), abs(self.z))
576 def __neg__(self):
577 return Vec3(-self.x, -self.y, -self.z)
579 def __add__(self, val):
581 return Vec3(self.x + val, self.y + val)
583 return Vec3(self.x + val.x, self.y + val.y, self.z + val.z)
587 def __sub__(self, val):
588 return self + (-val)
590 def __mul__(self, val):
594 return Vec3(self.x * val.x, self.y * val.y, self.z * val.z)
596 def __div__(self, val):
598 return Vec3(self.x / val.x, self.y / val.x, self.z / val.x)
600 return Vec3(self.x / val.x, self.y / val.y, self.z / val.z)
604 def boolAny(self): return Scalar(self.x or self.y or self.z)
605 def boolAll(self): return Scalar(self.x and self.y and self.z)
606 def boolNot(self): return Vec3(not self.x, not self.y, not self.z)
609 def __init__(self, x, y, z):
612 Vec3.__init__(self, x, y, z)
614 def typeString(self):
617 def __str__(self):
618 return "uvec3(%i, %i, %i)" % (self.x, self.y, self.z)
620 def abs(self):
621 return Vec3.abs(self).toUint()
624 def __init__(self, x, y, z, w):
626 self.x = x
627 self.y = y
628 self.z = z
629 self.w = w
631 def applyUnary(self, func): return Vec4(func(self.x), func(self.y), func(self.z), func(self.w))
632 def applyBinary(self, func, other): return Vec4(func(self.x, other.x), func(self.y, other.y), func(self.z, other.z), func(self.w, other.w))
634 def expandVec(self, val): return val.toVec4()
635 def toScalar(self): return Scalar(self.x)
636 def toVec2(self): return Vec2(self.x, self.y)
637 def toVec3(self): return Vec3(self.x, self.y, self.z)
638 def toVec4(self): return Vec4(self.x, self.y, self.z, self.w)
639 def toUVec2(self): return UVec2(self.x, self.y)
640 def toUVec3(self): return UVec3(self.x, self.y, self.z)
641 def toUVec4(self): return UVec4(self.x, self.y, self.z, self.w)
642 def toMat2(self): return Mat2(float(self.x), float(self.y), float(self.z), float(self.w))
643 def toMat4(self): return Mat4(float(self.x), 0.0, 0.0, 0.0, 0.0, float(self.y), 0.0, 0.0, 0.0, 0.0, float(self.z), 0.0, 0.0, 0.0, 0.0, float(self.w));
645 def toFloat(self): return Vec4(float(self.x), float(self.y), float(self.z), float(self.w))
646 def toInt(self): return Vec4(int(self.x), int(self.y), int(self.z), int(self.w))
647 def toUint(self): return UVec4(int(self.x), int(self.y), int(self.z), int(self.w))
648 def toBool(self): return Vec4(bool(self.x), bool(self.y), bool(self.z), bool(self.w))
650 def getNumScalars(self): return 4
651 def getScalars(self): return [self.x, self.y, self.z, self.w]
653 def typeString(self):
654 if isinstance(self.x, bool):
656 elif isinstance(self.x, int):
658 elif isinstance(self.x, float):
663 def vec4Swizzle(self):
666 def __str__(self):
667 if isinstance(self.x, bool):
668 return "bvec4(%s, %s, %s, %s)" % (str(self.x).lower(), str(self.y).lower(), str(self.z).lower(), str(self.w).lower())
669 elif isinstance(self.x, int):
670 return "ivec4(%i, %i, %i, %i)" % (self.x, self.y, self.z, self.w)
671 elif isinstance(self.x, float):
672 return "vec4(%s, %s, %s, %s)" % (self.x, self.y, self.z, self.w)
676 def distance(self, v):
678 return (self - v).length()
680 def dot(self, v):
682 return Scalar(self.x*v.x + self.y*v.y + self.z*v.z + self.w*v.w)
684 def abs(self):
685 if isinstance(self.x, bool):
686 return Vec4(self.x, self.y, self.z, self.w)
688 return Vec4(abs(self.x), abs(self.y), abs(self.z), abs(self.w))
690 def __neg__(self):
691 return Vec4(-self.x, -self.y, -self.z, -self.w)
693 def __add__(self, val):
695 return Vec3(self.x + val, self.y + val)
697 return Vec4(self.x + val.x, self.y + val.y, self.z + val.z, self.w + val.w)
701 def __sub__(self, val):
702 return self + (-val)
704 def __mul__(self, val):
708 return Vec4(self.x * val.x, self.y * val.y, self.z * val.z, self.w * val.w)
710 def __div__(self, val):
712 return Vec4(self.x / val.x, self.y / val.x, self.z / val.x, self.w / val.x)
714 return Vec4(self.x / val.x, self.y / val.y, self.z / val.z, self.w / val.w)
718 def boolAny(self): return Scalar(self.x or self.y or self.z or self.w)
719 def boolAll(self): return Scalar(self.x and self.y and self.z and self.w)
720 def boolNot(self): return Vec4(not self.x, not self.y, not self.z, not self.w)
723 def __init__(self, x, y, z, w):
726 Vec4.__init__(self, x, y, z, w)
728 def typeString(self):
731 def __str__(self):
732 return "uvec4(%i, %i, %i, %i)" % (self.x, self.y, self.z, self.w)
734 def abs(self):
735 return Vec4.abs(self).toUint()
739 def __init__ (self, numCols, numRows, scalars):
741 self.numCols = numCols
742 self.numRows = numRows
743 self.scalars = scalars
757 def get (self, colNdx, rowNdx):
758 assert 0 <= colNdx and colNdx < self.numCols
759 assert 0 <= rowNdx and rowNdx < self.numRows
760 return self.scalars[colNdx*self.numRows + rowNdx]
762 def set (self, colNdx, rowNdx, scalar):
763 assert 0 <= colNdx and colNdx < self.numCols
764 assert 0 <= rowNdx and rowNdx < self.numRows
765 self.scalars[colNdx*self.numRows + rowNdx] = scalar
767 def toMatrix (self, numCols, numRows):
769 for col in range(0, min(self.numCols, numCols)):
770 for row in range(0, min(self.numRows, numRows)):
771 res.set(col, row, self.get(col, row))
774 def toMat2 (self): return self.toMatrix(2, 2)
775 def toMat2x3 (self): return self.toMatrix(2, 3)
776 def toMat2x4 (self): return self.toMatrix(2, 4)
777 def toMat3x2 (self): return self.toMatrix(3, 2)
778 def toMat3 (self): return self.toMatrix(3, 3)
779 def toMat3x4 (self): return self.toMatrix(3, 4)
780 def toMat4x2 (self): return self.toMatrix(4, 2)
781 def toMat4x3 (self): return self.toMatrix(4, 3)
782 def toMat4 (self): return self.toMatrix(4, 4)
784 def typeString(self):
785 if self.numRows == self.numCols:
786 return "mat%d" % self.numRows
788 return "mat%dx%d" % (self.numCols, self.numRows)
790 def __str__(self):
791 return "%s(%s)" % (self.typeString(), ", ".join(["%s" % s for s in self.scalars]))
793 def isTypeEqual (self, other):
794 return isinstance(other, Mat) and self.numRows == other.numRows and self.numCols == other.numCols
796 def isEqual(self, other):
797 assert self.isTypeEqual(other)
798 return (self.scalars == other.scalars)
800 def compMul(self, val):
801 assert self.isTypeEqual(val)
802 return Mat(self.numRows, self.numCols, [self.scalars(i) * val.scalars(i) for i in range(self.numRows*self.numCols)])
805 def __init__(self, m00, m01, m10, m11):
806 Mat.__init__(self, 2, 2, [m00, m10, m01, m11])
809 def __init__(self, m00, m01, m02, m10, m11, m12, m20, m21, m22):
810 Mat.__init__(self, 3, 3, [m00, m10, m20,
815 def __init__(self, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33):
816 Mat.__init__(self, 4, 4, [m00, m10, m20, m30,