chiark / gitweb /
Add back the ultimaker platform, and made the platform mesh simpler.
[cura.git] / Cura / slice / cura_sf / fabmetheus_utilities / geometry / geometry_utilities / evaluate_fundamentals / euclid.py
1 """
2 Boolean geometry utilities.
3
4 """
5
6 from __future__ import absolute_import
7
8 from fabmetheus_utilities.vector3 import Vector3
9 from fabmetheus_utilities.vector3index import Vector3Index
10 from fabmetheus_utilities import euclidean
11 import math
12
13
14 __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
15 __credits__ = 'Art of Illusion <http://www.artofillusion.org/>'
16 __date__ = '$Date: 2008/02/05 $'
17 __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
18
19
20 def _getAccessibleAttribute(attributeName):
21         'Get the accessible attribute.'
22         if attributeName in globalAccessibleAttributeDictionary:
23                 return globalAccessibleAttributeDictionary[attributeName]
24         return None
25
26 def getComplex(x=0.0, y=0.0):
27         'Get the complex.'
28         return complex(x, y)
29
30 def getCylindrical(azimuthDegrees, radius=1.0, z=0.0):
31         'Get the cylindrical vector3 by degrees.'
32         return getCylindricalByRadians(math.radians(azimuthDegrees), radius, z)
33
34 def getCylindricalByRadians(azimuthRadians, radius=1.0, z=0.0):
35         'Get the cylindrical vector3 by radians.'
36         polar = radius * euclidean.getWiddershinsUnitPolar(azimuthRadians)
37         return Vector3(polar.real, polar.imag, z)
38
39 def getNestedVectorTestExample(x=0.0, y=0.0, z=0.0):
40         'Get the NestedVectorTestExample.'
41         return NestedVectorTestExample(Vector3(x, y, z))
42
43 def getPolar(angleDegrees, radius=1.0):
44         'Get the complex polar by degrees.'
45         return radius * euclidean.getWiddershinsUnitPolar(math.radians(angleDegrees))
46
47 def getPolarByRadians(angleRadians, radius=1.0):
48         'Get the complex polar by radians.'
49         return radius * euclidean.getWiddershinsUnitPolar(angleRadians)
50
51 def getSpherical(azimuthDegrees, elevationDegrees, radius=1.0):
52         'Get the spherical vector3 unit by degrees.'
53         return getSphericalByRadians(math.radians(azimuthDegrees), math.radians(elevationDegrees), radius)
54
55 def getSphericalByRadians(azimuthRadians, elevationRadians, radius=1.0):
56         'Get the spherical vector3 unit by radians.'
57         elevationComplex = euclidean.getWiddershinsUnitPolar(elevationRadians)
58         azimuthComplex = euclidean.getWiddershinsUnitPolar(azimuthRadians) * elevationComplex.real
59         return Vector3(azimuthComplex.real, azimuthComplex.imag, elevationComplex.imag) * radius
60
61 def getVector3(x=0.0, y=0.0, z=0.0):
62         'Get the vector3.'
63         return Vector3(x, y, z)
64
65 def getVector3Index(index=0, x=0.0, y=0.0, z=0.0):
66         'Get the vector3.'
67         return Vector3Index(index, x, y, z)
68
69
70 class NestedVectorTestExample(object):
71         'Class to test local attribute.'
72         def __init__(self, vector3):
73                 'Get the accessible attribute.'
74                 self.vector3 = vector3
75
76         def _getAccessibleAttribute(self, attributeName):
77                 "Get the accessible attribute."
78                 if attributeName == 'vector3':
79                         return getattr(self, attributeName, None)
80                 return None
81
82
83 globalAccessibleAttributeDictionary = {
84         'complex' : getComplex,
85         'getCylindrical' : getCylindrical,
86         'getCylindricalByRadians' : getCylindricalByRadians,
87         'getPolar' : getPolar,
88         'getPolarByRadians' : getPolarByRadians,
89         'getSpherical' : getSpherical,
90         'getSphericalByRadians' : getSphericalByRadians,
91         'NestedVectorTestExample' : getNestedVectorTestExample,
92         'Vector3' : getVector3,
93         'Vector3Index' : getVector3Index}