-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathputellipsoid.cpp
35 lines (31 loc) · 922 Bytes
/
putellipsoid.cpp
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
#include "putellipsoid.h"
#include <math.h>
PutEllipsoid::PutEllipsoid() {}
PutEllipsoid::~PutEllipsoid() {}
void PutEllipsoid::draw(Sculptor &t)
{
t.setColor(r, g, b, a);
for (int i = xcenter - rx; i < xcenter + rx; i++) {
for (int j = ycenter - ry; j < ycenter + ry; j++) {
for (int k = zcenter - rz; k < zcenter + rz; k++) {
float eq = sqrt(pow(i - xcenter, 2) + pow(j - ycenter, 2) + pow(k - zcenter, 2));
if (eq <= 1) {
t.putVoxel(i, j, k);
}
}
}
}
}
PutEllipsoid::PutEllipsoid(int xcenter, int ycenter, int zcenter, int rx, int ry, int rz, float r, float g, float b, float a)
{
this->xcenter = xcenter;
this->ycenter = ycenter;
this->zcenter = zcenter;
this->rx = rx;
this->ry = ry;
this->rz = rz;
this->r = r;
this->g = g;
this->b = b;
this->a = a;
}