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):
134 def __init__(self):
137 def uniformVec4(self, count, mn, mx):
144 def uniformBVec4(self, count):
150 # def uniform(self,
216 def __init__(self, x):
217 self.x = x
219 def applyUnary(self, func): return Scalar(func(self.x))
220 def applyBinary(self, func, other): return Scalar(func(self.x, other.x))
222 def isEqual(self, other): assert isinstance(other, Scalar); return (self.x == other.x)
224 def expandVec(self, val): return val
225 def toScalar(self): return Scalar(self.x)
226 def toVec2(self): return Vec2(self.x, self.x)
227 def toVec3(self): return Vec3(self.x, self.x, self.x)
228 def toVec4(self): return Vec4(self.x, self.x, self.x, self.x)
229 def toMat2(self): return self.toVec2().toMat2()
230 def toMat3(self): return self.toVec3().toMat3()
231 def toMat4(self): return self.toVec4().toMat4()
233 def toFloat(self): return Scalar(float(self.x))
234 def toInt(self): return Scalar(int(self.x))
235 def toBool(self): return Scalar(bool(self.x))
237 def getNumScalars(self): return 1
238 def getScalars(self): return [self.x]
240 def typeString(self):
241 if isinstance(self.x, bool):
243 elif isinstance(self.x, int):
245 elif isinstance(self.x, float):
250 def vec4Swizzle(self):
253 def __str__(self):
254 return "%s" % self.x
256 def length(self):
257 return Scalar(abs(self.x))
259 def distance(self, v):
261 return Scalar(abs(self.x - v.x))
263 def dot(self, v):
265 return Scalar(self.x * v.x)
267 def normalize(self):
268 return Scalar(glslSign(self.x))
270 def __neg__(self):
271 return Scalar(-self.x)
273 def __add__(self, val):
275 return Scalar(self.x + val.x)
277 def __sub__(self, val):
278 return self + (-val)
280 def __mul__(self, val):
282 return Scalar(self.x * val.x)
284 return Vec2(self.x * val.x, self.x * val.y)
286 return Vec3(self.x * val.x, self.x * val.y, self.x * val.z)
288 return Vec4(self.x * val.x, self.x * val.y, self.x * val.z, self.x * val.w)
292 def __div__(self, val):
294 return Scalar(self.x / val.x)
296 return Vec2(self.x / val.x, self.x / val.y)
298 return Vec3(self.x / val.x, self.x / val.y, self.x / val.z)
300 return Vec4(self.x / val.x, self.x / val.y, self.x / val.z, self.x / val.w)
313 def isEqual(self, other):
315 return (self.getScalars() == other.getScalars())
317 def length(self):
318 return Scalar(math.sqrt(self.dot(self).x))
320 def normalize(self):
321 return self * Scalar(1.0 / self.length().x)
323 def swizzle(self, indexList):
324 inScalars = self.getScalars()
328 def __init__(self):
332 def __init__(self, x, y):
334 self.x = x
335 self.y = y
337 def applyUnary(self, func): return Vec2(func(self.x), func(self.y))
338 def applyBinary(self, func, other): return Vec2(func(self.x, other.x), func(self.y, other.y))
340 def expandVec(self, val): return val.toVec2()
341 def toScalar(self): return Scalar(self.x)
342 def toVec2(self): return Vec2(self.x, self.y)
343 def toVec3(self): return Vec3(self.x, self.y, 0.0)
344 def toVec4(self): return Vec4(self.x, self.y, 0.0, 0.0)
345 def toMat2(self): return Mat2(float(self.x), 0.0, 0.0, float(self.y));
347 def toFloat(self): return Vec2(float(self.x), float(self.y))
348 def toInt(self): return Vec2(int(self.x), int(self.y))
349 def toBool(self): return Vec2(bool(self.x), bool(self.y))
351 def getNumScalars(self): return 2
352 def getScalars(self): return [self.x, self.y]
354 def typeString(self):
355 if isinstance(self.x, bool):
357 elif isinstance(self.x, int):
359 elif isinstance(self.x, float):
364 def vec4Swizzle(self):
367 def __str__(self):
368 if isinstance(self.x, bool):
369 return "bvec2(%s, %s)" % (str(self.x).lower(), str(self.y).lower())
370 elif isinstance(self.x, int):
371 return "ivec2(%i, %i)" % (self.x, self.y)
372 elif isinstance(self.x, float):
373 return "vec2(%s, %s)" % (self.x, self.y)
377 def distance(self, v):
379 return (self - v).length()
381 def dot(self, v):
383 return Scalar(self.x*v.x + self.y*v.y)
385 def __neg__(self):
386 return Vec2(-self.x, -self.y)
388 def __add__(self, val):
390 return Vec2(self.x + val, self.y + val)
392 return Vec2(self.x + val.x, self.y + val.y)
396 def __sub__(self, val):
397 return self + (-val)
399 def __mul__(self, val):
403 return Vec2(self.x * val.x, self.y * val.y)
405 def __div__(self, val):
407 return Vec2(self.x / val.x, self.y / val.x)
410 return Vec2(self.x / val.x, self.y / val.y)
412 def boolAny(self): return Scalar(self.x or self.y)
413 def boolAll(self): return Scalar(self.x and self.y)
414 def boolNot(self): return Vec2(not self.x, not self.y)
417 def __init__(self, x, y, z):
419 self.x = x
420 self.y = y
421 self.z = z
423 def applyUnary(self, func): return Vec3(func(self.x), func(self.y), func(self.z))
424 def applyBinary(self, func, other): return Vec3(func(self.x, other.x), func(self.y, other.y), func(self.z, other.z))
426 def expandVec(self, val): return val.toVec3()
427 def toScalar(self): return Scalar(self.x)
428 def toVec2(self): return Vec2(self.x, self.y)
429 def toVec3(self): return Vec3(self.x, self.y, self.z)
430 def toVec4(self): return Vec4(self.x, self.y, self.z, 0.0)
431 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));
433 def toFloat(self): return Vec3(float(self.x), float(self.y), float(self.z))
434 def toInt(self): return Vec3(int(self.x), int(self.y), int(self.z))
435 def toBool(self): return Vec3(bool(self.x), bool(self.y), bool(self.z))
437 def getNumScalars(self): return 3
438 def getScalars(self): return [self.x, self.y, self.z]
440 def typeString(self):
441 if isinstance(self.x, bool):
443 elif isinstance(self.x, int):
445 elif isinstance(self.x, float):
450 def vec4Swizzle(self):
453 def __str__(self):
454 if isinstance(self.x, bool):
455 return "bvec3(%s, %s, %s)" % (str(self.x).lower(), str(self.y).lower(), str(self.z).lower())
456 elif isinstance(self.x, int):
457 return "ivec3(%i, %i, %i)" % (self.x, self.y, self.z)
458 elif isinstance(self.x, float):
459 return "vec3(%s, %s, %s)" % (self.x, self.y, self.z)
463 def distance(self, v):
465 return (self - v).length()
467 def dot(self, v):
469 return Scalar(self.x*v.x + self.y*v.y + self.z*v.z)
471 def cross(self, v):
473 return Vec3(self.y*v.z - v.y*self.z,
474 self.z*v.x - v.z*self.x,
475 self.x*v.y - v.x*self.y)
477 def __neg__(self):
478 return Vec3(-self.x, -self.y, -self.z)
480 def __add__(self, val):
482 return Vec3(self.x + val, self.y + val)
484 return Vec3(self.x + val.x, self.y + val.y, self.z + val.z)
488 def __sub__(self, val):
489 return self + (-val)
491 def __mul__(self, val):
495 return Vec3(self.x * val.x, self.y * val.y, self.z * val.z)
497 def __div__(self, val):
499 return Vec3(self.x / val.x, self.y / val.x, self.z / val.x)
503 def boolAny(self): return Scalar(self.x or self.y or self.z)
504 def boolAll(self): return Scalar(self.x and self.y and self.z)
505 def boolNot(self): return Vec3(not self.x, not self.y, not self.z)
508 def __init__(self, x, y, z, w):
510 self.x = x
511 self.y = y
512 self.z = z
513 self.w = w
515 def applyUnary(self, func): return Vec4(func(self.x), func(self.y), func(self.z), func(self.w))
516 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))
518 def expandVec(self, val): return val.toVec4()
519 def toScalar(self): return Scalar(self.x)
520 def toVec2(self): return Vec2(self.x, self.y)
521 def toVec3(self): return Vec3(self.x, self.y, self.z)
522 def toVec4(self): return Vec4(self.x, self.y, self.z, self.w)
523 def toMat2(self): return Mat2(float(self.x), float(self.y), float(self.z), float(self.w))
524 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));
526 def toFloat(self): return Vec4(float(self.x), float(self.y), float(self.z), float(self.w))
527 def toInt(self): return Vec4(int(self.x), int(self.y), int(self.z), int(self.w))
528 def toBool(self): return Vec4(bool(self.x), bool(self.y), bool(self.z), bool(self.w))
530 def getNumScalars(self): return 4
531 def getScalars(self): return [self.x, self.y, self.z, self.w]
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 "bvec4(%s, %s, %s, %s)" % (str(self.x).lower(), str(self.y).lower(), str(self.z).lower(), str(self.w).lower())
549 elif isinstance(self.x, int):
550 return "ivec4(%i, %i, %i, %i)" % (self.x, self.y, self.z, self.w)
551 elif isinstance(self.x, float):
552 return "vec4(%s, %s, %s, %s)" % (self.x, self.y, self.z, self.w)
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 + self.w*v.w)
564 def __neg__(self):
565 return Vec4(-self.x, -self.y, -self.z, -self.w)
567 def __add__(self, val):
569 return Vec3(self.x + val, self.y + val)
571 return Vec4(self.x + val.x, self.y + val.y, self.z + val.z, self.w + val.w)
575 def __sub__(self, val):
576 return self + (-val)
578 def __mul__(self, val):
582 return Vec4(self.x * val.x, self.y * val.y, self.z * val.z, self.w * val.w)
584 def __div__(self, val):
586 return Vec4(self.x / val.x, self.y / val.x, self.z / val.x, self.w / val.x)
590 def boolAny(self): return Scalar(self.x or self.y or self.z or self.w)
591 def boolAll(self): return Scalar(self.x and self.y and self.z and self.w)
592 def boolNot(self): return Vec4(not self.x, not self.y, not self.z, not self.w)
596 def __init__ (self, numCols, numRows, scalars):
598 self.numCols = numCols
599 self.numRows = numRows
600 self.scalars = scalars
610 def get (self, colNdx, rowNdx):
611 assert 0 <= colNdx and colNdx < self.numCols
612 assert 0 <= rowNdx and rowNdx < self.numRows
613 return self.scalars[colNdx*self.numRows + rowNdx]
615 def set (self, colNdx, rowNdx, scalar):
616 assert 0 <= colNdx and colNdx < self.numCols
617 assert 0 <= rowNdx and rowNdx < self.numRows
618 self.scalars[colNdx*self.numRows + rowNdx] = scalar
620 def toMatrix (self, numCols, numRows):
622 for col in range(0, min(self.numCols, numCols)):
623 for row in range(0, min(self.numRows, numRows)):
624 res.set(col, row, self.get(col, row))
627 def toMat2 (self): return self.toMatrix(2, 2)
628 def toMat2x3 (self): return self.toMatrix(2, 3)
629 def toMat2x4 (self): return self.toMatrix(2, 4)
630 def toMat3x2 (self): return self.toMatrix(3, 2)
631 def toMat3 (self): return self.toMatrix(3, 3)
632 def toMat3x4 (self): return self.toMatrix(3, 4)
633 def toMat4x2 (self): return self.toMatrix(4, 2)
634 def toMat4x3 (self): return self.toMatrix(4, 3)
635 def toMat4 (self): return self.toMatrix(4, 4)
637 def typeString(self):
638 if self.numRows == self.numCols:
639 return "mat%d" % self.numRows
641 return "mat%dx%d" % (self.numCols, self.numRows)
643 def __str__(self):
644 return "%s(%s)" % (self.typeString(), ", ".join([str(s) for s in self.scalars]))
646 def isTypeEqual (self, other):
647 return isinstance(other, Mat) and self.numRows == other.numRows and self.numCols == other.numCols
649 def isEqual(self, other):
650 assert self.isTypeEqual(other)
651 return (self.scalars == other.scalars)
653 def compMul(self, val):
654 assert self.isTypeEqual(val)
655 return Mat(self.numRows, self.numCols, [self.scalars(i) * val.scalars(i) for i in range(self.numRows*self.numCols)])
658 def __init__(self, m00, m01, m10, m11):
659 Mat.__init__(self, 2, 2, [m00, m10, m01, m11])
662 def __init__(self, m00, m01, m02, m10, m11, m12, m20, m21, m22):
663 Mat.__init__(self, 3, 3, [m00, m10, m20,
668 def __init__(self, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33):
669 Mat.__init__(self, 4, 4, [m00, m10, m20, m30,