Skip to content

Commit 940d879

Browse files
committed
Fixing bug in surface. Also adding relevant example.
1 parent 87cfb48 commit 940d879

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

arrayfire/graphics.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,28 +175,28 @@ def plot3(self, line, title=None):
175175
_cell = _Cell(self._r, self._c, title, self._cmap)
176176
safe_call(backend.get().af_draw_plot3(self._wnd, line.arr, ct.pointer(_cell)))
177177

178-
def surface(self, z_vals, x_vals, y_vals, title=None):
178+
def surface(self, x_vals, y_vals, z_vals, title=None):
179179
"""
180180
Renders the input array as a 3D surface plot.
181181
182182
Paramters
183183
---------
184184
185-
z_vals: af.Array.
186-
A 1 dimensional array containing Z co-ordinates.
187-
188185
x_vals: af.Array.
189186
A 1 dimensional array containing X co-ordinates.
190187
191188
y_vals: af.Array.
192189
A 1 dimensional array containing Y co-ordinates.
193190
191+
z_vals: af.Array.
192+
A 1 dimensional array containing Z co-ordinates.
193+
194194
title: str.
195195
Title used for the plot.
196196
"""
197197
_cell = _Cell(self._r, self._c, title, self._cmap)
198198
safe_call(backend.get().af_draw_surface(self._wnd,
199-
z_vals.arr, x_vals.arr, y_vals.arr,
199+
x_vals.arr, y_vals.arr, z_vals.arr,
200200
ct.pointer(_cell)))
201201

202202
def hist(self, X, min_val, max_val, title=None):

examples/graphics/surface.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/python
2+
3+
#######################################################
4+
# Copyright (c) 2015, ArrayFire
5+
# All rights reserved.
6+
#
7+
# This file is distributed under 3-clause BSD license.
8+
# The complete license agreement can be obtained at:
9+
# http://arrayfire.com/licenses/BSD-3-Clause
10+
########################################################
11+
12+
import arrayfire as af
13+
import math
14+
15+
af.info()
16+
17+
POINTS = 30
18+
N = 2 * POINTS
19+
20+
x = (af.iota(d0 = N, d1 = 1, tile_dims = (1, N)) - POINTS) / POINTS
21+
y = (af.iota(d0 = 1, d1 = N, tile_dims = (N, 1)) - POINTS) / POINTS
22+
23+
win = af.Window(800, 800, "3D Surface example using ArrayFire")
24+
25+
t = 0
26+
while not win.close():
27+
t = t + 0.07
28+
z = 10*x*-af.abs(y) * af.cos(x*x*(y+t))+af.sin(y*(x+t))-1.5;
29+
win.surface(x, y, z)

0 commit comments

Comments
 (0)