/** * ( begin auto-generated from PVector_rotate.xml ) * * Rotate the vector by an angle (only 2D vectors), magnitude remains the same * * ( end auto-generated ) * * @webref pvector:method * @usage web_application * @brief Rotate the vector by an angle (2D only) * @param theta the angle of rotation */ public void rotate(float theta) { float xTemp = x; // Might need to check for rounding errors like with angleBetween function? x = x*PApplet.cos(theta) - y*PApplet.sin(theta); y = xTemp*PApplet.sin(theta) + y*PApplet.cos(theta); }
/** * ( begin auto-generated from PVector_rotate.xml ) * * Rotate the vector by an angle (only 2D vectors), magnitude remains the same * * ( end auto-generated ) * * @webref pvector:method * @usage web_application * @brief Rotate the vector by an angle (2D only) * @param theta the angle of rotation */ public PVector rotate(float theta) { float temp = x; // Might need to check for rounding errors like with angleBetween function? x = x*PApplet.cos(theta) - y*PApplet.sin(theta); y = temp*PApplet.sin(theta) + y*PApplet.cos(theta); return this; }
static private void invRotate(PMatrix3D matrix, float angle, float v0, float v1, float v2) { float c = PApplet.cos(-angle); float s = PApplet.sin(-angle); float t = 1.0f - c; matrix.preApply((t*v0*v0) + c, (t*v0*v1) - (s*v2), (t*v0*v2) + (s*v1), 0, (t*v0*v1) + (s*v2), (t*v1*v1) + c, (t*v1*v2) - (s*v0), 0, (t*v0*v2) - (s*v1), (t*v1*v2) + (s*v0), (t*v2*v2) + c, 0, 0, 0, 0, 1); }
static private void invRotate(PMatrix3D matrix, float angle, float v0, float v1, float v2) { float c = PApplet.cos(-angle); float s = PApplet.sin(-angle); float t = 1.0f - c; matrix.preApply((t*v0*v0) + c, (t*v0*v1) - (s*v2), (t*v0*v2) + (s*v1), 0, (t*v0*v1) + (s*v2), (t*v1*v1) + c, (t*v1*v2) - (s*v0), 0, (t*v0*v2) - (s*v1), (t*v1*v2) + (s*v0), (t*v2*v2) + c, 0, 0, 0, 0, 1); }
float s = PApplet.sin(angle);
public static void sin(PApplet parent, PGraphics g, int amt, float freq, int xDiff, float size) { float v = (PApplet.sin((float) (parent.millis()) / 1000f * PConstants.TWO_PI * freq) + 1f) / 2f; g.noStroke(); g.ellipseMode(CENTER); g.fill(v * amt); g.ellipse(-xDiff, 0, size, size); g.ellipse(0, 0, size, size); g.ellipse(xDiff, 0, size, size); }
float s = PApplet.sin(angle);