I have a segment of code that updates an object's position based on Lorenz Attractor calculations. I would like to convert this to update an objects positions in a circular path at a set height on the y axis. I think I just need to change the x and z calculations but I'm not sure if that is correct or what to change to.

{ // Lorenz integration parameters double dt = 0.003; double s = -1.7; double b = 2.66; double r = 50; // Old vectors double D,Nx,Ny,Nz; double Dx0 = Dx; double Dy0 = Dy; double Dz0 = Dz; double Ux0 = Ux; double Uy0 = Uy; double Uz0 = Uz; // Fix degenerate case if (X==0 && Y==0 && Z==0) Y = Z = 40; // Update position Dx = s*(Y-X); Dy = X*(r-Z)-Y; Dz = X*Y - b*Z; X += dt*Dx; Y += dt*Dy; Z += dt*Dz; // Normalize DX D = sqrt(Dx*Dx+Dy*Dy+Dz*Dz); Dx /= D; Dy /= D; Dz /= D; // Calculate sideways Sx = Dy0*Dz-Dz0*Dy; Sy = Dz0*Dx-Dx0*Dz; Sz = Dx0*Dy-Dy0*Dx; // Calculate Up Ux = Dz*Sy - Dy*Sz; Uy = Dx*Sz - Dz*Sx; Uz = Dy*Sx - Dx*Sy; // Normalize Up D = sqrt(Ux*Ux+Uy*Uy+Uz*Uz); Ux /= D; Uy /= D; Uz /= D; // Eye and lookat position Ex = X-7*Dx; Ey = Y-7*Dy; Ez = Z-7*Dz; Ox = X; Oy = Y; Oz = Z; // Next DX Nx = s*(Y-X); Ny = X*(r-Z)-Y; Nz = X*Y - b*Z; // Pitch angle pitch = 180*acos(Dx*Dx0+Dy*Dy0+Dz*Dz0); // Roll angle D = (Ux*Ux0+Uy*Uy0+Uz*Uz0) / (Dx*Dx0+Dy*Dy0+Dz*Dz0); if (D>1) D = 1; roll = (Nx*Sx+Ny*Sy+Nz*Sz>0?+1:-1)*960*acos(D); // Yaw angle yaw = 0; // Power setting (0-1) if (Dy>0.8) pwr = 100; else if (Dy>-0.2) pwr = 20+100*Dy; else pwr = 0; }

Using the attached changes...I do get the object to move in a circular path and it appears to be updating direction properly, my object is pointing down, but that is not a problem with this segment of code. However, every half second or so, it rotates ~45 degrees and then rotates back. I'm not sure what is causing this.

if (fly) { // Lorenz integration parameters double dt = 0.003; // Old vectors double D,Nx,Ny,Nz; double Dx0 = Dx; double Dy0 = Dy; double Dz0 = Dz; double Ux0 = Ux; double Uy0 = Uy; double Uz0 = Uz; // Fix degenerate case if (X==0 && Y==0 && Z==0) Y = Z = 40; // Update position Dx = -sin(B52_direction); Dy = 20; Dz = cos(B52_direction); X += dt*Dx; Y += 0; Z += dt*Dz; // Normalize DX D = sqrt(Dx*Dx+Dy*Dy+Dz*Dz); Dx /= D; Dy /= D; Dz /= D; // Calculate sideways Sx = Dy0*Dz-Dz0*Dy; Sy = Dz0*Dx-Dx0*Dz; Sz = Dx0*Dy-Dy0*Dx; // Calculate Up Ux = Dz*Sy - Dy*Sz; Uy = Dx*Sz - Dz*Sx; Uz = Dy*Sx - Dx*Sy; // Normalize Up D = sqrt(Ux*Ux+Uy*Uy+Uz*Uz); Ux /= D; Uy /= D; Uz /= D; // Eye and lookat position Ex = X-7*Dx; Ey = Y-7*Dy; Ez = Z-7*Dz; Ox = X; Oy = Y; Oz = Z; // Next DX Nx = -sin(B52_direction); Ny = 20; Nz = cos(B52_direction); // Pitch angle pitch = 180*acos(Dx*Dx0+Dy*Dy0+Dz*Dz0); // Roll angle D = (Ux*Ux0+Uy*Uy0+Uz*Uz0) / (Dx*Dx0+Dy*Dy0+Dz*Dz0); if (D>1) D = 1; roll = (Nx*Sx+Ny*Sy+Nz*Sz>0?+1:-1)*960*acos(D); // Yaw angle yaw = 0; // Power setting (0-1) if (Dy>0.8) pwr = 100; else if (Dy>-0.2) pwr = 20+100*Dy; else pwr = 0; } // Static Roll/Pitch/Yaw else { Ex = -2*dim*Sin(th)*Cos(ph); Ey = +2*dim *Sin(ph); Ez = +2*dim*Cos(th)*Cos(ph); Ox = Oy = Oz = 0; X = Z = 0; Y = 20; Dx = 1; Dy = 0; Dz = 0; Ux = 0; Uy = 1; Uz = 0; }

I am now getting the proper circular motion I was looking for. I'm not having an issue with the diameter in the scenario. I am not sure how to increase it. My direction variable increments every iteration by .04.

if (fly) { // Lorenz integration parameters double dt = 0.003; // Old vectors double D,Nx,Ny,Nz; double Dx0 = Dx; double Dy0 = Dy; double Dz0 = Dz; double Ux0 = Ux; double Uy0 = Uy; double Uz0 = Uz; // Fix degenerate case if (X==0 && Y==0 && Z==0) Y = Z = 40; // Update position Dx = -sin(B52_direction); Dy = 20; Dz = cos(B52_direction); X += dt*Dx; Y += 0; Z += dt*Dz; // Normalize DX D = sqrt(Dx*Dx+Dy*Dy+Dz*Dz); Dx /= D; Dy /= D; Dz /= D; // Calculate sideways Sx = Dy0*Dz-Dz0*Dy; Sy = Dz0*Dx-Dx0*Dz; Sz = Dx0*Dy-Dy0*Dx; // Calculate Up Ux = Dz*Sy - Dy*Sz; Uy = Dx*Sz - Dz*Sx; Uz = Dy*Sx - Dx*Sy; // Normalize Up D = sqrt(Ux*Ux+Uy*Uy+Uz*Uz); Ux /= D; Uy /= D; Uz /= D; // Eye and lookat position Ex = X-7*Dx; Ey = Y-7*Dy; Ez = Z-7*Dz; Ox = X; Oy = Y; Oz = Z; // Next DX Nx = -sin(B52_direction); Ny = 20; Nz = cos(B52_direction); // Pitch angle pitch = 180*acos(Dx*Dx0+Dy*Dy0+Dz*Dz0); // Roll angle D = (Ux*Ux0+Uy*Uy0+Uz*Uz0) / (Dx*Dx0+Dy*Dy0+Dz*Dz0); if (D>1) D = 1; roll = 0; // Yaw angle yaw = 0; // Power setting (0-1) if (Dy>0.8) pwr = 100; else if (Dy>-0.2) pwr = 20+100*Dy; else pwr = 0; } // Static Roll/Pitch/Yaw else { Ex = -2*dim*Sin(th)*Cos(ph); Ey = +2*dim *Sin(ph); Ez = +2*dim*Cos(th)*Cos(ph); Ox = Oy = Oz = 0; X = Z = 0; Y = 20; Dx = 1; Dy = 0; Dz = 0; Ux = 0; Uy = 1; Uz = 0; }

Not a complete soultion but the rght suggestion for getting circular motion. The rest fell in to place after that.

0

Featured Post

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough. To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…

Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris.
Well, a long time ago, in a galaxy far far away, I was…

Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210 (2 * 3 * 5 * 7) or 2310 (2 * 3 * 5 * 7 * 11).
The larger templa…