<
PrototypeJungle
>

Geometry

PrototypeJungle defines geometric types (implemented as prototypes) and methods that are directly accessible in any context. Geometic objects are used in the course of geometric computations, but do not have a visible form. shapes, covered in the next section, are the visible elements.

The geometric types and their properties and methods are specified below.

Point

Constructor:

Point.mk(x:number>,y:number>)

Properties of Point p,

p.x:number;
p.y:number;

Methods for Point p,

p.plus(q:Point):Point; // returns the vector sum p and q
p.difference(q:Point):Point; // returns the vector subtraction of q from p
p.distance(q:Point):number; // returns distance from p to q
p.normalize():Point; // returns p shrunk or extended to a unit vector with the same direction
p.normal():Point; // returns a vector which is orthogonal to p
p.times(s:number):Point; // return p scaled by s

LineSegment

LineSegment.mk(end0:Point,end1:Point)

Properties of LineSegment s,

s.end0:Point;
s.end1:Point;

Methods for LineSegment s,

s.length():number;
s.pointAlong(n:number):Point; // for 0<=n<=1, returns the point fraction n of the way from end0 to end1

Rectangle

Rectangle.mk(corner:Point:extent:Point)

Properties of Rectangle r,

s.corner:Point;
s.extent:Point;

Methods for Rectangle r,

r.contains(p:Point):boolean;

Circle

Circle.mk(center:Point,radius:number)

Properties of Circle c,

c.center:Point
c.radius:number;

Point3d

Constructor:

Point3d.mk(x:number,y:number,z:number)

Properties of Point3d p,

p.x:number;
p.y:number;
p.z:number;

Methods for Point3d p,

p.plus(q:Point):Point3d; // returns the vector sum p and q
p.difference(q:Point):Point3d;; // returns the vector subtraction of q from p
p.distance(q:Point):number; // returns distance from p to q
p.times(s:number):Point3d;; // return p scaled by s

Camera

Constructor:

Camera.mk(focalPoint:Point3d,focalLength:number,scaling:number,axis:string)

axis should be one of "x", "y", "z"

Properties of Camera c,

c.focalPoint
c.focalLength:number;
p.scaling:number;
p.axis:string; // one of 'x','y','z'

Methods for Camera c,

c.project(p:Point3d); // returns the projection of p onto the focal plane