To draw an "Ellipse" to the given parameters.

This project received 18 bids from talented freelancers with an average bid price of £100 GBP.

Get free quotes for a project like this
Project Budget
£20 - £250 GBP
Total Bids
Project Description

Purpose of Task:

To draw an "Ellipse" to the given parameters.

Definition of Function to be edited:

drawEllipse(x, y, rx, ry, nSteps)

The ellipse should be drawn with its centre at the given co-ordinates (x and y) and with radius of (rx and ry).

Since it is impossible to draw a perfect Ellipse on the screen, in practice, an Ellipse is normally approximated by a set of short, straight lines; the more lines, the better the "Ellipse". In this case the final parameter (nSteps) defines how many line segments to divide the Ellipse into.

Note: The co-ordinates of any point on the edge of an Ellipse centred at the origin may be obtained from the following equations.

X = RadiusX * cosine(*) Y = RadiusY * sine(*)

{where * is an angle.}

The JavaScript functions [url removed, login to view] (angle) and [url removed, login to view] (angle) can be invoked, but they require the angle to be given in radians.

Note: To convert an angle from degrees to radians multiply the angle by */180 (where * = 3 .1415926).

Getting Started

The Task 1 folder contains the files you need.

When you click on the “New Ellipse” button it reads in the parameter values from the user interface and calls the function newEllipse (…) to draw the circle.

A red cross is drawn at the centre of the Ellipse and a green “radiusX-line” so that you can check that your Ellipse is drawn in the correct position and at the correct size.

Screen shot from Task 1 without changes made

Screen shot from Task 1 with changes made

There is no data file for this program; when you run the application, you will be asked to enter:

• X and Y of circle

• Radius X

• Radius Y

• Number of Steps

N.B. The X and Y axes have their origin in the centre of the drawing area which is of size 800 by 600. (Each square is 10 x 10 pixels)

Further Guidance

• You will find that the drawEllipse (…) function already exists in “[url removed, login to view]”, although it does not work correctly; you need to modify it.

• Only edit the drawEllipse (…) function.

• To help you with choosing coordinates for testing your code note that the drawing area has a coordinate range from (–400 to +400 in X) & (-300 to + 300 in Y), with the origin in the centre.

• Remember to test your Ellipse with a range of values for position, radius and steps.

Looking to make some money?

  • Set your budget and the timeframe
  • Outline your proposal
  • Get paid for your work

Hire Freelancers who also bid on this project

    • Forbes
    • The New York Times
    • Time
    • Wall Street Journal
    • Times Online