geometry-calculator-x
A Javascript library that performs the C.A.G Geometry Calculator requirements.
ECMAScript compatibility shims for legacy JavaScript engines
es5-shim.js
monkey-patches a JavaScript context to contain all EcmaScript 5
methods that can be faithfully emulated with a legacy JavaScript engine.
es5-sham.js
monkey-patches other ES5 methods as closely as possible.
For these methods, as closely as possible to ES5 is not very close.
Many of these shams are intended only to allow code to be written to ES5
without causing run-time errors in older engines. In many cases,
this means that these shams cause many ES5 methods to silently fail.
Decide carefully whether this is what you want. Note: es5-sham.js requires
es5-shim.js to be able to work properly.
json3.js
monkey-patches the EcmaScript 5 JSON implimentation faithfully.
es6-shim.js
provides compatibility shims so that legacy JavaScript engines
behave as closely as possible to ECMAScript 6 (Harmony).
es7-shim.js
provides compatibility shims so that legacy JavaScript engines
behave as closely as possible to ECMAScript 7.
See: https://gist.github.com/KristofferV/952493dfa53b1349e684c4fa2f203403
Version: 1.0.1
Author: Xotic750 Xotic750@gmail.com
License: MIT
Copyright: Xotic750
- geometry-calculator-x
- ~Shape
new Shape()
.circumference()
⇒number
.area()
⇒number
- ~RightAngledTriangle
new RightAngledTriangle(x, y, h)
.circumference()
⇒number
.area()
⇒number
- ~Rectangle
new Rectangle(x, y)
.circumference()
⇒number
.area()
⇒number
- ~Circle
new Circle(r)
.circumference()
⇒number
.area()
⇒number
- ~ShapesArea
new ShapesArea(...varArgs)
.area()
⇒number
- ~Shape
geometry-calculator-x~Shape
Kind: inner class of geometry-calculator-x
this: {Shape}
Access: public
- ~Shape
new Shape()
.circumference()
⇒number
.area()
⇒number
new Shape()
The base object for other shapes to inherit from.
shape.circumference()
⇒ number
Zero for the default shape.
Kind: instance method of Shape
Returns: number
- The circumference unit distance measurement.
this: {Shape}
Access: public
shape.area()
⇒ number
Zero for the default shape.
Kind: instance method of Shape
Returns: number
- The area unit square measurement.
this: {Shape}
Access: public
geometry-calculator-x~RightAngledTriangle
Kind: inner class of geometry-calculator-x
this: {RightAngledTriangle}
Access: public
- ~RightAngledTriangle
new RightAngledTriangle(x, y, h)
.circumference()
⇒number
.area()
⇒number
new RightAngledTriangle(x, y, h)
A right triangle (American English) or right-angled triangle (British English) is a triangle in which one angle is a right angle (that is, a 90-degree angle). The relation between the sides and angles of a right triangle is the basis for trigonometry.
Param | Type | Description |
---|---|---|
x | number |
The base unit distance measurement. |
y | number |
The height unit distance measurement. |
h | number |
The hypotenuse unit distance measurement. |
Example
var triangle = 3 4 5;console; // 12console; // 6
rightAngledTriangle.circumference()
⇒ number
The circumference of a right angled triangle is the sum of the three side lengths.
Circumference = x + y + h
Kind: instance method of RightAngledTriangle
Returns: number
- The circumference unit distance measurement.
this: {RightAngledTriangle}
Access: public
rightAngledTriangle.area()
⇒ number
The area is given by the area formula for an arbitrary triangle.
Area = (1 / 2) * B * h
If the triangle is right angled, as in this case, the side y is the same as the height an y is the same as the base line.
Area = (1 / 2) * y * x
Kind: instance method of RightAngledTriangle
Returns: number
- The area unit square measurement.
this: {RightAngledTriangle}
Access: public
geometry-calculator-x~Rectangle
Kind: inner class of geometry-calculator-x
this: {Rectangle}
Access: public
- ~Rectangle
new Rectangle(x, y)
.circumference()
⇒number
.area()
⇒number
new Rectangle(x, y)
In Euclidean plane geometry, a rectangle is a quadrilateral with four right angles. It can also be defined as an equiangular quadrilateral, since equiangular means that all of its angles are equal. It can also be defined as a parallelogram containing a right angle. A rectangle with four sides of equal length is a square. The term oblong is occasionally used to refer to a non-square rectangle.
Param | Type | Description |
---|---|---|
x | number |
The base unit distance measurement. |
y | number |
The height unit distance measurement. |
Example
var rectangle = 3 4 5;console; // 14console; // 12
rectangle.circumference()
⇒ number
The circumference of a rectangle is the sum of the two side lengths then doubled.
Circumference = (x + y) * 2
Kind: instance method of Rectangle
Returns: number
- The circumference unit distance measurement.
this: {Rectangle}
Access: public
rectangle.area()
⇒ number
To find the area of a rectangle, multiply the length by the width.
Area = x * y
Kind: instance method of Rectangle
Returns: number
- The area unit square measurement.
this: {Rectangle}
Access: public
geometry-calculator-x~Circle
Kind: inner class of geometry-calculator-x
this: {Circle}
Access: public
- ~Circle
new Circle(r)
.circumference()
⇒number
.area()
⇒number
new Circle(r)
A circle is a simple closed shape in Euclidean geometry. It is the set of all points in a plane that are at a given distance from a given point, the centre; equivalently it is the curve traced out by a point that moves so that its distance from a given point is constant. The distance between any of the points and the centre is called the radius.
Param | Type | Description |
---|---|---|
r | number |
The radius unit distance measurement. |
Example
var circle = 3;console; // 18.84console; // 28.27
circle.circumference()
⇒ number
The circumference of a circle relates to one of the most important mathematical constants in all of mathematics.
Circumference = 2 * PI * r
Kind: instance method of Circle
Returns: number
- The circumference unit distance measurement.
this: {Circle}
Access: public
circle.area()
⇒ number
To find the area of a circle.
Area = PI * (r^2)
Kind: instance method of Circle
Returns: number
- The area unit square measurement.
this: {Circle}
Access: public
geometry-calculator-x~ShapesArea
Kind: inner class of geometry-calculator-x
this: {ShapesArea}
Access: public
- ~ShapesArea
new ShapesArea(...varArgs)
.area()
⇒number
new ShapesArea(...varArgs)
Total area of multiple shapes (not only triangles and rectangles but also other types of shapes that impliment #area).
Param | Type | Description |
---|---|---|
...varArgs | Object |
The shapes to calculate the total area of. |
Example
var shapesArea = triangle rectangle circle;console; // 46.27
shapesArea.area()
⇒ number
To find the area of all the shapes supplied to the constructor.
Kind: instance method of ShapesArea
Returns: number
- The area unit square measurement.
this: {ShapesArea}
Access: public