MCPcopy Create free account
hub / github.com/PageBot/PageBot / Degrees

Class Degrees

Lib/pagebot/toolbox/units.py:2661–2709  ·  view source on GitHub ↗

Store the value as degrees. >>> from math import pi >>> a = degrees(30) >>> a 30deg >>> a.degrees 30 >>> a = degrees(90) >>> a.degrees, a.radians (90, 0.5) >>> a + 30 - 15 105deg >>> 20 + a # Reverse addition casts the number into degree value 110

Source from the content-addressed store, hash-verified

2659 tan = property(_get_tan)
2660
2661class Degrees(Angle):
2662 """Store the value as degrees.
2663
2664 >>> from math import pi
2665 >>> a = degrees(30)
2666 >>> a
2667 30deg
2668 >>> a.degrees
2669 30
2670 >>> a = degrees(90)
2671 >>> a.degrees, a.radians
2672 (90, 0.5)
2673 >>> a + 30 - 15
2674 105deg
2675 >>> 20 + a # Reverse addition casts the number into degree value
2676 110deg
2677 >>> 120 - a
2678 30deg
2679 >>> a/2 # Create integer value for whole angles
2680 45deg
2681 >>> a/2.4
2682 37.5deg
2683 >>> a//3
2684 30deg
2685 """
2686 def __repr__(self):
2687 return '%sdeg' % self.angle
2688
2689 def asValue(self, angle):
2690 """Answers the value of angle of the same type as self.
2691
2692 >>> degrees(30).asValue(60)
2693 60
2694 >>> degrees(30).asValue(degrees(15))
2695 15
2696 >>> degrees(30).asValue(radians(0.5))
2697 90
2698 """
2699 if isinstance(angle, Angle):
2700 return angle.degrees
2701 return angle or 0
2702
2703 def _get_degrees(self):
2704 return self.angle
2705 degrees = property(_get_degrees)
2706
2707 def _get_radians(self):
2708 return math.radians(self.angle/math.pi)
2709 radians = property(_get_radians)
2710
2711def degrees(angle):
2712 if isinstance(angle, Angle):

Callers 1

degreesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected