Computer Graphics using OpenGL Microsoft Visual Studio Input

Computer Graphics using OpenGL (Microsoft Visual Studio)

•Input 6 points.

•The first 3 points for the first circle.

•The second 3 points for the second circle.

•Compute the intersections.

•Allow the user move the centres of the circles using the mouse and the keyboard.

•If any of the circle is moved then update the intersections.

•Also draw the inscribed circles using the three points and find their intersections! (Figure 4.49).

L Circle. LOX

Solution

step1: create some balls

the import tant thing which we have to note here is to make origin as center of cirlce for good practice

Step2: check for over laps

if (firstBall.x + firstBall.radius + secondBall.radius > secondBall.x

&& firstBall.x < secondBall.x + firstBall.radius + secondBall.radius

&& firstBall.y + firstBall.radius + secondBall.radius > secondBall.y

&& firstBall.y < seconBall.y + firstBall.radius + secondBall.radius)

{

//determines whether two circles are near to each other or not

}

once they are near we can compute hte distance by using this code

distance = Math.sqrt(

            ((firstBall.x - secondBall.x) * (firstBall.x – secondBall.x))

          + ((firstBall.y - secondBall.y) * (firstBall.y – secondBall.y))

           );

if (distance < firstBall.radius + secondBall.radius)

{

    //balls have collided

}

step 3:caluclate collision points

collisionPointX =

((firstBall.x * secondBall.radius) + (secondBall.x * firstBall.radius))

/ (firstBall.radius + secondBall.radius);

collisionPointY =

((firstBall.y * secondBall.radius) + (secondBall.y * firstBall.radius))

/ (firstBall.radius + secondBall.radius);

hope ths would help you to get a intiation....Alll the best

Computer Graphics using OpenGL (Microsoft Visual Studio) •Input 6 points. •The first 3 points for the first circle. •The second 3 points for the second circle.
Computer Graphics using OpenGL (Microsoft Visual Studio) •Input 6 points. •The first 3 points for the first circle. •The second 3 points for the second circle.

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site