If you're seeing this message, it means we're having trouble loading external resources on our website.

তোমার যদি কোন ওয়েব ফিল্টার দেওয়া থাকে, তাহলে দয়া করে নিশ্চিত কর যে *.kastatic.org এবং *.kasandbox.org ডোমেইনগুলো উন্মুক্ত।

মূল বিষয়বস্তু

বল এবং ত্রিকোণমিতি: দোলক

Do you remember Newton’s laws of motion from a couple sections back? Back then, we used those laws to calculate the acceleration of an object, so that we could compute and draw its new position in the world. Now, we're going to use those laws to calculate the acceleration of a pendulum, to compute and draw its position along the swing. And as it turns out, we're going to need some help from trigonometry along the way.
A pendulum is a bob suspended from a pivot. Obviously a real-world pendulum would live in a 3D space, but we’re going to look at a simpler scenario, a pendulum in a 2D space—the program canvas .
দোলকের কোণগুলোর চিত্র
In the Forces section, we learned how a force (such as the force of gravity shown in the diagram above) causes an object to accelerate: F, equals, M, times, A, or A, equals, F, slash, M.
In this case, however, the pendulum bob doesn’t simply fall to the ground, since it is attached by an arm to the pivot point. Instead the bob swings towards its rest position, and we want to compute the acceleration of the bob along the swing. We'll call that its angular acceleration, since the pendulum is accelerating along an arc.
In order to determine the pendulum's angular acceleration, we need to break the force of gravity into components. One component will be along the pendulum arm. We can ignore that component because the arm is always pulling against it, cancelling it out. The other component is perpendicular to the arm. That's the one we care about, because it's pulling the pendulum "sideways", making it swing. Let’s zoom in on the pendulum diagram and visualize those components of the gravity force:
F, start subscript, g, end subscript is the total force of gravity downwards. F, start subscript, p, end subscript is the force of gravity perpendicular to the arm of the pendulum, pointing in the opposite direction that the pendulum is swinging. F, start subscript, a, end subscript is the force of gravity along the arm, which we'll ignore since it won't affect the angular acceleration.
Now how do we calculate F, start subscript, p, end subscript? This is where we use our trigonometry. F, start subscript, g, end subscript is the hypotenuse of a right triangle, and theta is the angle of the arm. Sine equals opposite over hypotenuse:
sine, left parenthesis, theta, right parenthesis, equals, start fraction, F, start subscript, p, end subscript, divided by, F, start subscript, g, end subscript, end fraction
সুতরাং:
F, start subscript, p, end subscript, equals, F, start subscript, g, end subscript, dot, sine, left parenthesis, theta, right parenthesis
Great, we now have a simple formula to compute F, start subscript, p, end subscript. Now let's circle back to our original question: What is the angular acceleration of the pendulum? Once we find the angular acceleration, we’ll be able to apply our rules of motion to find the new angle for the pendulum.
angular velocity (কৌণিক বেগ) = angular velocity + angular acceleration (কৌণিক ত্বরণ)
angle (কোণ) = angle + angular velocity
Thanks to Newton’s second law, we know that there is a relationship between force and acceleration, namely F, equals, M, times, A, or A, equals, F, slash, M, and we can use that relationship with the formula above to compute an angular acceleration. See if you can follow this:
Starting with:
perpendicular force = force due to gravity * sine(θ)
Then we divide the right side by mass, to come up with the acceleration, based on Newton's second law:
angular acceleration = (force due to gravity * sine(θ)) / mass
Then we realize we can just divide the force due to gravity by mass, and that's the same thing as acceleration due to gravity, so we'll just substitute that:
angular acceleration = acceleration due to gravity * sine (θ)
চমৎকার! আমরা এখন কৌণিক ত্বরণ হিসাব করতে পারি।
We can simplify that even further, since we're ProcessingJS programmers and not physicists. Yes, we know that the acceleration due to gravity on earth is 9.8 meters per second squared. But this number isn’t relevant to us. In our programs, our "gravity" is just an arbitrary number, one that we can use to scale the acceleration to something that feels right.
angular acceleration (কৌণিক ত্বরণ) = gravity (অভিকর্ষ) * sine(θ)
Amazing. After all that, the formula is so simple. You might be wondering, why bother going through the derivation at all? I mean, learning is great and all, but we could have easily just said, "Hey, the angular acceleration of a pendulum is some constant times the sine of the angle."
This is just another moment in which we remind ourselves that the purpose of the course is not to learn how pendulums swing or gravity works. The point is to think creatively about how things can move about the screen in a computationally based graphics system. The pendulum is just a case study. If you can understand the approach to programming a pendulum, then however you choose to design your onscreen world, you can apply the same techniques.
অবশ্য, আমাদের এখনও বাকি আছে। হয়তো আমাদের সহজ, সরল সূত্র নিয়েই আমরা খুবই খুশি, কিন্তু এটাকে কোডে পরিণত করতে হবে। এটাই অবজেক্ট অরিয়েন্টেড প্রোগ্রামিং জ্ঞানকে কাজে লাগিয়ে একটি Pendulum (দোলক) অবজেক্ট তৈরি করার উপযুক্ত সময়। অবজেক্টটি তৈরি করার জন্য দোলকটির সকল বৈশিষ্ট্যের একটি তালিকে নিচে দেওয়া হল:
  • arm length (কার্যকরী দৈর্ঘ্য)
  • angle (কোণ)
  • angular velocity (কৌণিক বেগ)
  • angular acceleration (কৌণিক ত্বরণ)
এছাড়াও দোলকের ঝুলন বিন্দু নির্দিষ্ট করে দিতে হবে, আমরা কন্সট্রাক্টর নিয়ে এভাবে শুরু করি:
var Pendulum  = function(origin, armLength) {
    this.origin = origin;
    this.armLength = armLength;

    this.angle = PI/4;
    this.aVelocity = 0.0;
    this.aAcceleration = 0.0;
};
সূত্রানুযায়ী দোলকের কোণ আপডেট করার জন্য একটি update() মেথড তৈরি করতে হবে।
Pendulum.prototype.update = function() {
    // ধ্রুবক
    var gravity = 0.4;
    // ত্বরণের হিসাব
    this.aAcceleration = -1 * gravity * sin(this.angle);
    // বেগ বৃদ্ধি
    this.aVelocity += this.aAcceleration;
    // কোণ বৃদ্ধি
    this.angle += this.aVelocity;    
};
…এছাড়াও দোলকটিকে আঁকার জন্য display() মেথড লাগবে। একটি গুরুত্বপূর্ণ প্রশ্ন হল: “এখন, দোলকটিকে কথায় আঁকবো?” কোণ এবং কার্যকরী দৈর্ঘ্য জানা আছে, কিন্তু দোলকের ঝুলন বিন্দু (ধরি এটা উৎস বা origin) ও ববের অবস্থান (ধরি এটা অবস্থান বা position) উভয়ের জন্য x,y (কার্তেসিয়ান!) স্থানাঙ্ক কীভাবে বের করবো? এটা একটু কষ্টকর হলেও, উত্তরটি, আবারও হল ত্রিকোণমিতি। বামের চিত্রটি দেখা যাক।
মূলবিন্দু (origin) এবং কার্যকরী দৈর্ঘ্য (arm length) আমাদেরই তৈরি। ধরি, দোলকটিকে আমরা এভাবে তৈরি করি:
var p = new Pendulum(new PVector(100, 10), 125);
আমরা বর্তমান কোণকে angle এর বৈশিষ্ট্যে সংরক্ষণ করি। মূলবিন্দুর সাপেক্ষে, দোলকের অবস্থান একটি পোলার স্থানাঙ্ক: (r,angle)। এটিকে কার্তেসিয়ানে রূপান্তর করতে হবে। সৌভাগ্যক্রমে, আমরা কোণের অনুশীলনে পোলার থেকে কার্তেসিয়ানে রূপান্তরের সূত্র বের করেছিলাম। সেই অনুশীলনে, কোণ অনুভূমিক অক্ষের সাপেক্ষে ছিল, কিন্তু এখানে, এটা উল্লম্ব অক্ষের সাপেক্ষে আছে, এজন্য আমরা cos() এবং sin() এর পরিবর্তে যথাক্রমে sin() কে x অবস্থানের এবং cos() কে y অবস্থানের জন্য ব্যবহার করি। সুতরাং, রূপান্তরের সূত্র ব্যবহার করে আমরা মূলবিন্দুর সাপেক্ষে অবস্থানটি বের করতে পারি এবং তারপর এটাতে উৎসের অবস্থান যোগ করতে পারি:
this.position = new PVector(
   this.armLength * sin(this.angle),
   this.armLength * cos(this.angle));
this.position.add(this.origin);
stroke(0, 0, 0);
fill(175, 175, 175);
line(this.origin.x, this.origin.y, this.position.x, this.position.y);
ellipse(this.position.x, this.position.y, 16, 16);
সবকিছু করার আগে, আরেকটি কাজ করতে আমি ভুলে গিয়েছি। কিছুক্ষণ দোলকের কার্যকরী দৈর্ঘ্য নিয়ে চিন্তা করি। এটা কি একটি লোহার দন্ড? নাকি একটি তার? নাকি রাবার ব্যান্ড? এটা কীভাবে ঝুলন্ত বিন্দুর সাথে সংযুক্ত থাকে? এটা কত বড়? এটার ভর কত? আজ কি বেশি বায়ুপ্রবাহ আছে? এমন অনেক প্রস্নই করা যায় যা সিমুলেশনকে প্রভাবিত করে। অবশ্য, আমরা কল্পনার জগতে আছি, যেখানে দোলকের কার্যকরী দৈর্ঘ্য একটি অপ্রসারণশীল, ওজনহীন ও নমনীয় সুতা এবং একটি ভারী আয়তনহীন বব দিয়ে তৈরি।
যাই হোক, এতগুলো প্রশ্ন নিয়ে এখন মাথা ঘামানোর দরকার নেই, কৌণিক ত্বরণ বের করার জন্য আরেকটি চলক যোগ করতে হবে। সহজ রাখার জন্য, দোলকের ত্বরণ বের করার সময়, ধরে নেবো যে দোলকের কার্যকরী দৈর্ঘ্য হল 1। মজার বিষয় হল, কার্যকরী দৈর্ঘ্য দোলকের ত্বরণকে ব্যাপকভাবে প্রভাবিত করে: যত বড় দৈর্ঘ্য, তত ধীর ত্বরণ। সঠিকভাবে একটি দোলকের সিমুলেশন করার জন্য কার্যকরী দৈর্ঘ্য দিয়ে ভাগ করবো, এক্ষেত্রে armLength। বিস্তৃতভাবে জানার জন্য, সরল দোলকের ওয়েবসাইট দেখা উচিৎ।
this.aAcceleration = (-1 * gravity / this.armLength) * sin(this.angle);
আসলে, সত্যিকারের দোলক অবশ্যই ঘর্ষণ বল অনুভব করবে (ঝুলন বিন্দুতে) এবং বায়ু প্রতিবন্ধকতা সৃষ্টি করবে। আমাদের কোড অনুযায়ী, দোলকটি চিরকাল দোলন দেবে, তাই এটাকে আরও বাস্তবধর্মী করার জন্য “damping” (স্লথ) উপায় ব্যবহার করা হয়। উপায় বলার কারণ হল, ঘর্ষণ বলকে তৈরি করার চেয়ে (আমরা বলের অংশে যেমনটি করেছিলাম), প্রতি দোলনে কৌণিক বেগ হ্রাস করলেই যথার্থ ফলাফল পাবো। নিচের কোডটি প্রতি ফ্রেমের অ্যানিমেশনে 1% হারে বেগ হ্রাস করে (অথবা 99% দিয়ে গুণ করে):
this.aVelocity *= this.damping;
সবকিছু একত্র করলে আমরা নিচের উদাহরণটি পাই। ববকে নড়া চড়া করানো এবং উপর থেকে ফেলে দেওয়ার জন্য একটি সহজ পদ্ধতি যোগ করা হয়েছে। চেষ্টা করে দেখা যাক!

এই "প্রাকৃতিক সিমুলেশন" কোর্সটি নেওয়া হয়েছে Daniel Shiffman (ড্যানিয়েল শিফম্যান) এর লেখা "The Nature of Code" (কোডের প্রকৃতি) থেকে এবং এটি ক্রিয়েটিভ কমন্সের এট্রিবিউশন-নন কমার্শিয়াল 3.0 আনপোরটেড লাইসেন্সের অধিনস্ত।

আলোচনায় অংশ নিতে চাও?

কোন আলাপচারিতা নেই।
ইংরেজি জানো? খান একাডেমির ইংরেজি সাইটে আরো আলোচনা দেখতে এখানে ক্লিক কর।