Question: Given HTML Code: OO Please open Web Developer Tools Console to see output. Given is a tiny index.html page, which tries to load a script

 Given HTML Code: OO Please open Web Developer Tools Console to

Given HTML Code:

OO

Please open Web Developer Tools Console to see output.

Given is a tiny index.html page, which tries to load a script geometry.js. Task: Create the file traversal.js and implement a tiny object-oriented class hierarchy for some basic geometric primitives. The base class should be named Primitive and have a method getArea(), which results in undefined. Then, create derived classes ConvexPolygon, Quad, Triangle, and Circle. Create a constructor for primitives class that creates the primitive from given parameters. For instance, a circle would be created from a point and a radius. Override the getArea() method to calculate the area of primitives of the corresponding class. Finally, create a list of different primitives; iterate over the list and print type and area for each primitive to the JS console. Area of Triangle: Let p0=(x0,y0),p1=(x1,y1),p2=(x2,y2) be the three points of a triangle. Let (ux,uy)=(x1x0,y1y0) and (vx,vy)=(x2x0,y2y0) be the two vectors u and v from p0 to p1 and p2, respectively. Then the area A of the triangle is given by A=1/2uxvyuyvx. Area of Convex Polygon: A convex polygon with n3 vertices p0,p1,, pn1 can be split into n2 triangles with indices (0,1,2),(0,2,3),(0,4,5),, (0,n2,n1). The area of the of the convex polygon is simply the sum of the area of the triangles. Note that concave polygons are harder. Submission: Please add your name as a comment at the top of geometry.js and submit only this file. Extra Points: You can earn extra points if your code also adds an SVG element

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!