Sunday 17 May 2020

Chapter 13 // Exercise 11 - Principles & Practice Using C++

In this exercise I am using Visual Studio 2017 and the graphics files found here:
https://github.com/l-paz91/principles-practice/tree/master/Graphics%20Files

Chapter 13 // Exercise 11

Draw a 300-by-200-pixel ellipse. Draw a 400-pixel-long x axis and a 300-pixel-long y axis through the center of the ellipse. Mark the foci. Mark a point on the ellipse that is not on one of the axes. Draw the two lines from the foci to the point.

Github: https://github.com/l-paz91/principles-practice/blob/master/Chapter%2013/Exercise%2011

The first thing I did was google what a "Foci" was. Apparently it is the "focus points" of an ellipse. On a circle the focus points are dead center. One thing I had to keep in mind is that the foci lie on the major axis. The major axis is the axis that is the longest, so they could change between X and Y depending on the width/height of the ellipse.

Most formulas only tell you how to find the foci given that the center point is 0,0. However, our center point is 0+x, 0+y. I then realised that maybe I should not drink bacardi and pineapple when I'm programming because it took me 40 minutes to realise that the ellipse class already has the functions to find the foci.

In a previous exercise I already made a function to find any point on an ellipse given an angle, so the rest fell into place.






No comments:

Post a Comment