Skip to content

Commit 6029528

Browse files
djkapnerfcollman
authored andcommitted
adding polynomial2d scale and test (#128)
1 parent c14d5e0 commit 6029528

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

renderapi/transform/leaf/polynomial_models.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ def order(self):
8989
no_coeffs = len(self.params.ravel())
9090
return int((abs(np.sqrt(4 * no_coeffs + 1)) - 3) / 2)
9191

92+
@property
93+
def scale(self):
94+
"""tuple of scale for x, y"""
95+
if self.order > 0:
96+
scale = (self.params[0, 1], self.params[1, 2])
97+
else:
98+
# translation only has no scale impact
99+
scale = (1.0, 1.0)
100+
return scale
101+
92102
@property
93103
def dataString(self):
94104
"""dataString of polynomial"""

test/test_transform.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,18 @@ def test_invert_Affine():
167167
assert(np.allclose(am.concatenate(Iam).M, np.eye(3)))
168168

169169

170+
def test_polynomial_scale():
171+
p = np.transpose(np.array([[0, 0]]))
172+
t = renderapi.transform.Polynomial2DTransform(params=p)
173+
assert(t.order==0)
174+
assert(t.scale==(1.0, 1.0))
175+
176+
p = np.transpose(np.array([[0, 0], [1.1, 0], [0, 0.9]]))
177+
t = renderapi.transform.Polynomial2DTransform(params=p)
178+
assert(t.order==1)
179+
assert(t.scale==(1.1, 0.9))
180+
181+
170182
def test_Polynomial_estimation(use_numpy=False):
171183
if use_numpy:
172184
try:

0 commit comments

Comments
 (0)