forked from arrayfire/arrayfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot3.cpp
More file actions
46 lines (37 loc) · 1.28 KB
/
plot3.cpp
File metadata and controls
46 lines (37 loc) · 1.28 KB
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
/*******************************************************
* Copyright (c) 2014, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
********************************************************/
#include <arrayfire.h>
#include <math.h>
#include <cstdio>
using namespace af;
static const int ITERATIONS = 200;
static const float PRECISION = 1.0f / ITERATIONS;
int main(int, char**) {
try {
// Initialize the kernel array just once
af::info();
af::Window myWindow(800, 800, "3D Line Plot example: ArrayFire");
static float t = 0.1;
array Z = seq(0.1f, 10.f, PRECISION);
do {
array Y = sin((Z * t) + t) / Z;
array X = cos((Z * t) + t) / Z;
X = max(min(X, 1.0), -1.0);
Y = max(min(Y, 1.0), -1.0);
// Pts can be passed in as a matrix in the form n x 3, 3 x n
// or in the flattened xyz-triplet array with size 3n x 1
myWindow.plot(X, Y, Z);
t += 0.01;
} while (!myWindow.close());
} catch (af::exception& e) {
fprintf(stderr, "%s\n", e.what());
throw;
}
return 0;
}