forked from glumpy/glumpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
polar.py
61 lines (40 loc) · 1.45 KB
/
polar.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# -----------------------------------------------------------------------------
# Copyright (c) 2009-2016 Nicolas P. Rougier. All rights reserved.
# Distributed under the (new) BSD License.
# -----------------------------------------------------------------------------
"""
Polar projection
Regular projection using x as rho and y as theta.
The transform is connected to the following events:
* attach (initialization)
"""
from glumpy import library
from . transform import Transform
class PolarProjection(Transform):
""" Polar projection """
aliases = { "origin" : "polar_origin" }
def __init__(self, *args, **kwargs):
"""
Initialize the transform.
Note that parameters must be passed by name (param=value).
Kwargs parameters
-----------------
origin : float (default is 0)
Angle origin (radians)
"""
self._origin = Transform._get_kwarg("origin", kwargs) or 0.0
code = library.get("transforms/polar.glsl")
Transform.__init__(self, code, *args, **kwargs)
@property
def origin(self):
""" Angle origin (radians) """
return self._origin
@origin.setter
def origin(self, value):
""" Angle origin (radians) """
self._origin = float(value)
if self.is_attached:
self["origin"] = self._origin
def on_attach(self, program):
""" Initialization event """
self["origin"] = self._origin