This site requires JavaScript, please enable it in your browser!
Greenfoot back
ronald
ronald wrote ...

2020/3/31

pendulum

ronald ronald

2020/3/31

#
what is the difference between the velocity angle and the acceleration angle of a pendulum Thank you for your help
danpost danpost

2020/3/31

#
Pendulums have velocity and acceleration vectors. You need a reference vector to compare them to in order to construct angles.
ronald ronald

2020/3/31

#
it is the rocking of the ball which is the acceleration which indicates the speed if I understand correctly.
danpost danpost

2020/3/31

#
ronald wrote...
it is the rocking of the ball which is the acceleration which indicates the speed if I understand correctly.
That is phrased so poorly that it is impossible to determine what you are trying to say. Gravity is the accelerating force (or can be thought of as being). "rocking of the ball" is vague and needs a better, more technical, description. "speed" is also vague -- could be instantaneous, maximum or in general (referring to the frequency).
ronald ronald

2020/3/31

#
desolate for the phrase formulation, i try to place or is the speed and acceleration angle on a mathematical diagram, I try to understand the math formula of the pendulum
danpost danpost

2020/3/31

#
ronald wrote...
I try to understand the math formula of the pendulum
See the Wikipedia article on pendulum.
ronald ronald

2020/3/31

#
thanks this is what i was looking for a diagram is better than 1000 words I had trouble with speed and acceleration angles
ronald ronald

2020/4/1

#
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Pendulum here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Pendulum extends Actor
{
    
    private double angle = Math.PI / 2;
    private int length;
    
    public Pendulum(int length)
    {
        this.length = length;
        
    }
    
     /**
     * Act - do whatever the Pendulum wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    
    public void act() 
    {
        // Add your action code here.
        drawPendulum();
        run();
    }
    
    public void drawPendulum()
    {
        GreenfootImage gfim = new GreenfootImage(900,600);
        
        gfim.setColor(Color.WHITE);
        gfim.fillRect(0, 0, gfim.getWidth(), gfim.getHeight());
        gfim.setColor(Color.BLACK);
        int anchorX = gfim.getWidth() / 2, anchorY = gfim.getHeight() / 4;
        int ballX = anchorX + (int) (Math.sin(angle) * length);
        int ballY = anchorY + (int) (Math.cos(angle) * length); 
        gfim.drawLine(anchorX, anchorY, ballX, ballY);
        gfim.fillOval(anchorX - 3, anchorY - 4, 7, 7);
        gfim.fillOval(ballX - 7, ballY - 7, 14, 14);
        
        this.setImage(gfim);
    }
        
    public void run()
    {    
        double angleAccel, angleVelocity = 0, dt = 0.5;
        
            angleAccel = -9.81 / length * Math.sin(angle);
            angleVelocity += angleAccel * dt;
            angle += angleVelocity * dt;
            
            
        
    
    }
}
I started this pendulum code that I found in rosetta code, the pendulum stops net and does not swing anymore, Thank you for your help
Super_Hippo Super_Hippo

2020/4/1

#
Try to move line 52 to line 14.
ronald ronald

2020/4/1

#
great, thank you
You need to login to post a reply.