y-orbit tumbles from top to bottom as mouseY changes in Processing IDE
NickName:Joe Ask DateTime:2011-09-13T06:05:23

y-orbit tumbles from top to bottom as mouseY changes in Processing IDE

NOTE: this is in the Processing IDE

I am trying to get spherical orbiting down and i've almost got it. this is what i have so far:

float cameraTheta, cameraPhi, cameraRadius; //camera position in spherical coordinates
float camx, camy, camz;

void setup() {
  size(500, 500, P3D);
  background(255);
  cameraRadius = 200.0f;
  cameraTheta = 2.80;
  cameraPhi = 2.0;
  recomputeOrientation();
}


void draw() {
  background(255);
  lights();
  mouseMotion();
  camera(camx, camy, camz, 0, 0, 0, 0, -1, 0);
  sphereDetail(10);
  sphere(25);
}

void mouseMotion()
{
  if (mousePressed) {
    cameraTheta += (mouseX - pmouseX)*0.05;
    cameraPhi   += (mouseY - pmouseY)*0.05;
  }
  recomputeOrientation();     //update camera (x,y,z) based on (radius,theta,phi)
}

void recomputeOrientation()
{
  camx = cameraRadius * sin(cameraTheta)*sin(cameraPhi);
  camz = cameraRadius * -cos(cameraTheta)*sin(cameraPhi);
  camy = cameraRadius * -cos(cameraPhi);
  redraw();
}

the x rotation works great however the y rotation sort of tumbles from the top to the bottom and then back up again over and over as the mouseY changes, what i need is for it to continue to tumble in one direction as long as the mouse moves up and back the other direction as the mouse moves down. can anyone help me figure this out?

Copyright Notice:Content Author:「Joe」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/7394600/y-orbit-tumbles-from-top-to-bottom-as-mousey-changes-in-processing-ide

More about “y-orbit tumbles from top to bottom as mouseY changes in Processing IDE” related questions

y-orbit tumbles from top to bottom as mouseY changes in Processing IDE

NOTE: this is in the Processing IDE I am trying to get spherical orbiting down and i've almost got it. this is what i have so far: float cameraTheta, cameraPhi, cameraRadius; //camera position in

Show Detail

mouseX and mouseY parameters in processing?

Hi guys right now I am trying to get a bezier line to move in specific paremeters on the canvas with mouseX and mouseY in processing. I'm using the bezier as a mouth, and I want it to be controlled...

Show Detail

Making an object bounce of an other object that is moved by mouseY/mouseX in processing

I am pretty new with processing and need some help. I'm trying to build a simple kickball game. Easy idea: when the ball hits the yellow bar, the ball bounces of. To keep the ball "alive" you have to

Show Detail

Exporting a Processing Application to Web Processing IDE

I am working with Processing trying to develop a simple data visualization application for the number of people with Health Insurance in the US. I have the sketch working locally on my machine but I

Show Detail

How to alert var distance_all (from var distance_top + distance_bottom)?

How to alert var distance_all (from var distance_top + distance_bottom)? When mouse position top or bottom less than 100 px. it's will be alert distance_all (from var distance_top + distance_bott...

Show Detail

How to let a rectangle rotate around MouseX, MouseY in Processing

I am trying to lerp the positions of items in Processing. So that item one moves to item two with a little ease. In my code I have a small red rectangle and want to lerp its position to the green

Show Detail

Processing 3 IDE is half cyrillic

Recently I started to find interest in Processing and decided to download the offical Processing 3 IDE from https://processing.org/download/?processing. But half of the IDE is in cyrillic symbols.

Show Detail

CSS bottom border transition - expand from bottom right and Top

I need to add a touch of changes to my site. as of now when somebody Hover over the category box or button the border color changes with transition. I would like the transition happen from bottom r...

Show Detail

Processing in java (without IDE)

I have seen alot of information about running processing with java using an IDE (eclipse, netbeans). I wanted to know how to run processing from java without using an IDE. Could someone describe st...

Show Detail

Processing - How do I show a quadrant of the screen in a larger frame?

I want I have a splitscreen video that is split into 4 quadrants. I want to use Processing to take a clicked quadrant, and show the view in a larger, frame or window that is centered. Below I already

Show Detail