Take up computer programming and your ignorance of trig will come back to haunt you.
I am writing software in VB.NET. In that language, you can draw an ellipse on the screen by specifying the following properties of a "bounding rectangle": the x and y coordinates (in pixels) of the top left corner, and the width and height. Passing these values to the appropriate command will produce an ellipse with its major axis coinciding with the x or y plane (ie not lopsided), inscribed inside the bounding rectangle. Thus, the only properties of the ellipse I have readily available are the width and height at the centre, and I can also calculate the centre coordinates by adding to the top left coordinate of the bounding rectangle half the width and half the height, respectively.
Now, what I need is to draw another rectangle, but this one should be inscribed INSIDE the ellipse. It should have the same ratio of width to height as the original "bounding" rectangle, and should touch the ellipse at each of its four corners. To draw it, I need to specify the top left coordinate (x, y), and the width and height, just as I did for the bounding rectangle of the ellipse. In practice, since its centre will obviously coincide with that of the bounding rectangle and of the ellipse, and since the width/height ratio is the same as that of the bounding rectangle, all I need is just ONE of those values, the width or the height, or for that matter the x and y coordinates of the top left corner (ie the point where a line drawn from the centre to the top left corner of the bounding rectangle would cross the ellipse) from which deriving the others would be trivial, even for a duffer like me. But I have no idea where to start, except the suspicion that the solution will involve some combination of sines, cosines and square roots.
In case anyone's wondering about the point of this, the idea is to define an area inside an elliptical "speech bubble", drawn by the user, into which text can be written. Once I have the basic formula for the single inscribed rectangle (which would only be optimal for a single line of text) I will then try to adapt it to deal with multiple lines... but that's still some way off.
Many thanks in advance for any help anyone can offer
I am writing software in VB.NET. In that language, you can draw an ellipse on the screen by specifying the following properties of a "bounding rectangle": the x and y coordinates (in pixels) of the top left corner, and the width and height. Passing these values to the appropriate command will produce an ellipse with its major axis coinciding with the x or y plane (ie not lopsided), inscribed inside the bounding rectangle. Thus, the only properties of the ellipse I have readily available are the width and height at the centre, and I can also calculate the centre coordinates by adding to the top left coordinate of the bounding rectangle half the width and half the height, respectively.
Now, what I need is to draw another rectangle, but this one should be inscribed INSIDE the ellipse. It should have the same ratio of width to height as the original "bounding" rectangle, and should touch the ellipse at each of its four corners. To draw it, I need to specify the top left coordinate (x, y), and the width and height, just as I did for the bounding rectangle of the ellipse. In practice, since its centre will obviously coincide with that of the bounding rectangle and of the ellipse, and since the width/height ratio is the same as that of the bounding rectangle, all I need is just ONE of those values, the width or the height, or for that matter the x and y coordinates of the top left corner (ie the point where a line drawn from the centre to the top left corner of the bounding rectangle would cross the ellipse) from which deriving the others would be trivial, even for a duffer like me. But I have no idea where to start, except the suspicion that the solution will involve some combination of sines, cosines and square roots.
In case anyone's wondering about the point of this, the idea is to define an area inside an elliptical "speech bubble", drawn by the user, into which text can be written. Once I have the basic formula for the single inscribed rectangle (which would only be optimal for a single line of text) I will then try to adapt it to deal with multiple lines... but that's still some way off.
Many thanks in advance for any help anyone can offer