#### Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

# How to approximate an object?

edited April 2018

How to approximate an object using acceleration function and formulas from physics? Here is my program now. For some reasons it doesn't approximate my box correctly like in the real life.

``````camX = map(m, 0, width,-200,200);
camY = map(k, 0, width,-200,200);
camZ = map(n, 0, width,-200,200);
camera(-camY+300,0,-camY+200,-camZ,camX,0,0,-1,0)
fill (0,0,255);
box(150);

t1 =  0.7
aZ = accelerationZ;
S1 = Vox*t1 + (aZ*t1*t1)/2;
if (aZ>-0.2 && aZ<0.2) {Vox = 0}
else {Vox = Vox + aZ*t1;}
k = k + S1;
S1 = 0;
``````

I need to do it more realistic. Could you help me?

Tagged:

• Post all the code. That is not enough.

• ``````var camX;
var camY;
var camZ;
var Vox = 0;
var aZ = 0;
var k = 400;
var m = 400;
var n = 400;
var t1 = 0;

function setup()
{createCanvas(windowWidth, windowHeight, WEBGL);}

function draw(){
background(90);
camX = map(m, 0, width,-200,200);
camY = map(k, 0, width,-200,200);
camZ = map(n, 0, width,-200,200);
camera(-camY+300,0,-camY+200,-camZ,camX,0,0,-1,0)
fill (0,0,255);
box(150);

t1 =  0.7
aZ = accelerationZ;
S1 = Vox*t1 + (aZ*t1*t1)/2;
if (aZ>-0.2 && aZ<0.2) {Vox = 0}
else {Vox = Vox + aZ*t1;}
k = k + S1;
S1 = 0;}
``````
• What do you mean by approximate?

Movement pattern?

• Yes, I move my device and I want the camera in the program simulate the movement to and from the cube