Question: // Pendulum Assignment PVector origin; // Location of the arm orgin. PVector bob; // Location of the bob/circle. float len; // Length of the arm.
// Pendulum Assignment
PVector origin; // Location of the arm orgin.
PVector bob; // Location of the bob/circle.
float len; // Length of the arm.
float angle = PI/2; // Pendulum arm angle.
float aVel = 0.0; // Arm velocity.
float aAcc = 0.0; // Arm acceleration.
void setup(){
size(640, 360);
len = 180; // Length of the arm.
origin = new PVector(width/2,0); // Position of the arm on the screen.
bob = new PVector(width/2,5); // Position of the bob on the arm.
}
void draw(){
color c = color (0,0,0); // Color Black.
fill (c); // Fill bob with color black.
background(255,100,255); // Background color is Pink.
bob.x = origin.x + len * sin(angle); // The direction in which the bob moves in the x direction.
bob.y = origin.y + len * cos(angle); // The direction in which the bob moves in the y direction.
line(origin.x,origin.y,bob.x,bob.y); // The drawn location of the arm as it swings with the bob.
ellipse(bob.x,bob.y,32,32); // The drawn location of the bob as it swings with the arm.
aAcc = -0.01 * sin(angle); //Deacceleration of the Pendulum.
aVel += aAcc; // Standard Angular Motion Algorithm.
angle += aVel; // Standard Angular Motion Algorithm.
aVel *=0.99; // The velocity of the Pendulum in a given direction.
}
Hi we've created a code for a swinging pendulum in the computer programming language called Processing. Can you please code/plot the response over time for the Pendulum Angle in Processing. Please show the additional code you've added to plot the response over time for the Pendulum Angle.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
