MCPcopy Create free account
hub / github.com/scottbez1/splitflap / VectorAngle

Class VectorAngle

thirdparty/panelize.py:379–439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

377
378
379class VectorAngle( Vector ):
380
381 def __init__( self, name, x=None, y=None, a=0 ):
382 Vector.__init__( self, name, x, y )
383 self.a = a
384
385 def tag_value( self, factory, value ):
386 if self.x == None:
387 self.x = float(value)
388 elif self.y == None:
389 self.y = float(value)
390 #elif self.a == None:
391 # self.a = float(value)
392 #else:
393 # factory.parse_error( "too many values for '%s'" % self.obj_name )
394 else:
395 self.a = float(value)
396
397 def clone( self ):
398 return VectorAngle( self.obj_name, self.x, self.y, self.a )
399
400 def write_contents( self, writer ):
401 writer.write_float( self.x )
402 writer.write_float( self.y )
403 if self.a != None and self.a != 0:
404 writer.write_float( self.a )
405
406 def __add__( self, v ):
407 # +++ what about the angle???
408 return VectorAngle( self.obj_name, self.x+v.x, self.y+v.y, self.a )
409
410 def __sub__( self, v ):
411 # +++ what about the angle???
412 return VectorAngle( self.obj_name, self.x-v.x, self.y-v.y, self.a )
413
414 def __str__( self ):
415 if self.y == None:
416 return "<<<NONE>>>"
417 if self.a == 0:
418 return Vector.__str__( self )
419 return "%f/%f@%f" % ( self.x, self.y, self.a )
420
421 def unrot( self ):
422 #x = self.x
423 #y = self.y
424 #if self.a == 0:
425 # pass
426 #elif self.a == 90:
427 # x, y = y, -x
428 #elif self.a == 180:
429 # x, y = -x, -y
430 #elif self.a == 270:
431 # x, y = -y, x
432 #else:
433 # # +++ sin/cos???
434 # raise Exception( "unsupported angle" )
435 #return Vector( self.obj_name, x, y )
436 return self.rotate( self.a )

Callers 11

cloneMethod · 0.85
__add__Method · 0.85
__sub__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
rel_vectorMethod · 0.85
vectorMethod · 0.85
add_rotationMethod · 0.85
draw_textMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected