My Project
graphics/plot3.cpp
/*******************************************************
* 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 <cstdio>
#include <math.h>
using namespace af;
static const int ITERATIONS = 200;
static const float PRECISION = 1.0f/ITERATIONS;
int main(int argc, char *argv[])
{
try {
// Initialize the kernel array just once
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);
array Pts = join(1, X, Y, Z);
//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.plot3(Pts);
t+=0.01;
} while(!myWindow.close());
} catch (af::exception& e) {
fprintf(stderr, "%s\n", e.what());
throw;
}
return 0;
}
af::seq
seq is used to create seq for indexing af::array
Definition: seq.h:44
af::info
AFAPI void info()
af::join
AFAPI array join(const int dim, const array &first, const array &second)
Join 2 arrays along dim.
af::array
A multi dimensional data container.
Definition: array.h:32
af
Definition: algorithm.h:13
af::max
AFAPI array max(const array &in, const int dim=-1)
C++ Interface for maximum values in an array.
af::Window::close
bool close()
Check if window is marked for close.
af::sin
AFAPI array sin(const array &in)
C++ Interface for sin.
af::exception
Definition: exception.h:24
arrayfire.h
af::cos
AFAPI array cos(const array &in)
C++ Interface for cos.
af::Window::plot3
void plot3(const array &in, const char *title=NULL)
Renders the input array as an 3d line plot to the window.
af::exception::what
virtual const char * what() const
Definition: exception.h:45
af::Window
Window object to render af::arrays.
Definition: graphics.h:36
af::min
AFAPI array min(const array &in, const int dim=-1)
C++ Interface for minimum values in an array.