Finished Geom JSDocs

This commit is contained in:
Richard Davey 2020-02-04 16:19:42 +00:00
parent 11a24cdb73
commit 0ee6d16c17
15 changed files with 67 additions and 61 deletions

View file

@ -8,14 +8,14 @@ var MATH_CONST = require('../../math/const');
var Angle = require('./Angle');
/**
* [description]
* Returns the x component of the normal vector of the given line.
*
* @function Phaser.Geom.Line.NormalX
* @since 3.0.0
*
* @param {Phaser.Geom.Line} line - The Line object to get the normal value from.
*
* @return {number} [description]
* @return {number} The x component of the normal vector of the line.
*/
var NormalX = function (line)
{

View file

@ -15,10 +15,10 @@ var Point = require('./Point');
*
* @generic {Phaser.Geom.Point} O - [out,$return]
*
* @param {Phaser.Geom.Point[]} points - [description]
* @param {Phaser.Geom.Point} [out] - [description]
* @param {Phaser.Types.Math.Vector2Like[]} points - An array of Vector2Like objects to get the geometric center of.
* @param {Phaser.Geom.Point} [out] - A Point object to store the output coordinates in. If not given, a new Point instance is created.
*
* @return {Phaser.Geom.Point} [description]
* @return {Phaser.Geom.Point} A Point object representing the geometric center of the given points.
*/
var GetCentroid = function (points, out)
{

View file

@ -14,10 +14,10 @@ var Rectangle = require('../rectangle/Rectangle');
*
* @generic {Phaser.Geom.Rectangle} O - [out,$return]
*
* @param {Phaser.Geom.Point[]} points - [description]
* @param {Phaser.Geom.Rectangle} [out] - [description]
* @param {Phaser.Types.Math.Vector2Like[]} points - An array of Vector2Like objects to get the AABB from.
* @param {Phaser.Geom.Rectangle} [out] - A Rectangle object to store the results in. If not given, a new Rectangle instance is created.
*
* @return {Phaser.Geom.Rectangle} [description]
* @return {Phaser.Geom.Rectangle} A Rectangle object holding the AABB values for the given points.
*/
var GetRectangleFromPoints = function (points, out)
{

View file

@ -7,7 +7,7 @@
var Point = require('./Point');
/**
* [description]
* Returns the linear interpolation point between the two given points, based on `t`.
*
* @function Phaser.Geom.Point.Interpolate
* @since 3.0.0

View file

@ -8,18 +8,19 @@ var Point = require('./Point');
var GetMagnitudeSq = require('./GetMagnitudeSq');
/**
* [description]
* Calculates the vector projection of `pointA` onto the nonzero `pointB`. This is the
* orthogonal projection of `pointA` onto a straight line paralle to `pointB`.
*
* @function Phaser.Geom.Point.Project
* @since 3.0.0
*
* @generic {Phaser.Geom.Point} O - [out,$return]
*
* @param {Phaser.Geom.Point} pointA - [description]
* @param {Phaser.Geom.Point} pointB - [description]
* @param {Phaser.Geom.Point} [out] - [description]
* @param {Phaser.Geom.Point} pointA - Point A, to be projected onto Point B.
* @param {Phaser.Geom.Point} pointB - Point B, to have Point A projected upon it.
* @param {Phaser.Geom.Point} [out] - The Point object to store the position in. If not given, a new Point instance is created.
*
* @return {Phaser.Geom.Point} [description]
* @return {Phaser.Geom.Point} A Point object holding the coordinates of the vector projection of `pointA` onto `pointB`.
*/
var Project = function (pointA, pointB, out)
{

View file

@ -7,18 +7,19 @@
var Point = require('./Point');
/**
* [description]
* Calculates the vector projection of `pointA` onto the nonzero `pointB`. This is the
* orthogonal projection of `pointA` onto a straight line paralle to `pointB`.
*
* @function Phaser.Geom.Point.ProjectUnit
* @since 3.0.0
*
* @generic {Phaser.Geom.Point} O - [out,$return]
*
* @param {Phaser.Geom.Point} pointA - [description]
* @param {Phaser.Geom.Point} pointB - [description]
* @param {Phaser.Geom.Point} [out] - [description]
* @param {Phaser.Geom.Point} pointA - Point A, to be projected onto Point B. Must be a normalized point with a magnitude of 1.
* @param {Phaser.Geom.Point} pointB - Point B, to have Point A projected upon it.
* @param {Phaser.Geom.Point} [out] - The Point object to store the position in. If not given, a new Point instance is created.
*
* @return {Phaser.Geom.Point} [description]
* @return {Phaser.Geom.Point} A unit Point object holding the coordinates of the vector projection of `pointA` onto `pointB`.
*/
var ProjectUnit = function (pointA, pointB, out)
{

View file

@ -7,15 +7,15 @@
var Contains = require('./Contains');
/**
* [description]
* Checks the given Point again the Polygon to see if the Point lays within its vertices.
*
* @function Phaser.Geom.Polygon.ContainsPoint
* @since 3.0.0
*
* @param {Phaser.Geom.Polygon} polygon - [description]
* @param {Phaser.Geom.Point} point - [description]
* @param {Phaser.Geom.Polygon} polygon - The Polygon to check.
* @param {Phaser.Geom.Point} point - The Point to check if it's within the Polygon.
*
* @return {boolean} [description]
* @return {boolean} `true` if the Point is within the Polygon, otherwise `false`.
*/
var ContainsPoint = function (polygon, point)
{

View file

@ -8,18 +8,22 @@ var Perimeter = require('./Perimeter');
var Point = require('../point/Point');
/**
* Position is a value between 0 and 1 where 0 = the top-left of the rectangle and 0.5 = the bottom right.
* Calculates the coordinates of a point at a certain `position` on the Rectangle's perimeter.
*
* The `position` is a fraction between 0 and 1 which defines how far into the perimeter the point is.
*
* A value of 0 or 1 returns the point at the top left corner of the rectangle, while a value of 0.5 returns the point at the bottom right corner of the rectangle. Values between 0 and 0.5 are on the top or the right side and values between 0.5 and 1 are on the bottom or the left side.
*
* @function Phaser.Geom.Rectangle.GetPoint
* @since 3.0.0
*
* @generic {Phaser.Geom.Point} O - [out,$return]
*
* @param {Phaser.Geom.Rectangle} rectangle - [description]
* @param {number} position - [description]
* @param {(Phaser.Geom.Point|object)} [out] - [description]
* @param {Phaser.Geom.Rectangle} rectangle - The Rectangle to get the perimeter point from.
* @param {number} position - The normalized distance into the Rectangle's perimeter to return.
* @param {(Phaser.Geom.Point|object)} [out] - An object to update with the `x` and `y` coordinates of the point.
*
* @return {Phaser.Geom.Point} [description]
* @return {Phaser.Geom.Point} The updated `output` object, or a new Point if no `output` object was given.
*/
var GetPoint = function (rectangle, position, out)
{

View file

@ -8,18 +8,18 @@ var Point = require('../point/Point');
/**
* The size of the Rectangle object, expressed as a Point object
* with the values of the width and height properties.
* Returns the size of the Rectangle, expressed as a Point object.
* With the value of the `width` as the `x` property and the `height` as the `y` property.
*
* @function Phaser.Geom.Rectangle.GetSize
* @since 3.0.0
*
* @generic {Phaser.Geom.Point} O - [out,$return]
*
* @param {Phaser.Geom.Rectangle} rect - [description]
* @param {(Phaser.Geom.Point|object)} [out] - [description]
* @param {Phaser.Geom.Rectangle} rect - The Rectangle to get the size from.
* @param {(Phaser.Geom.Point|object)} [out] - The Point object to store the size in. If not given, a new Point instance is created.
*
* @return {(Phaser.Geom.Point|object)} [description]
* @return {(Phaser.Geom.Point|object)} A Point object where `x` holds the width and `y` holds the height of the Rectangle.
*/
var GetSize = function (rect, out)
{

View file

@ -9,20 +9,20 @@ var Point = require('../point/Point');
/**
* Return an array of points from the perimeter of the rectangle
* each spaced out based on the quantity or step required
* Returns an array of points from the perimeter of the Rectangle, where each point is spaced out based
* on either the `step` value, or the `quantity`.
*
* @function Phaser.Geom.Rectangle.MarchingAnts
* @since 3.0.0
*
* @generic {Phaser.Geom.Point[]} O - [out,$return]
*
* @param {Phaser.Geom.Rectangle} rect - [description]
* @param {number} step - [description]
* @param {integer} quantity - [description]
* @param {(array|Phaser.Geom.Point[])} [out] - [description]
* @param {Phaser.Geom.Rectangle} rect - The Rectangle to get the perimeter points from.
* @param {number} [step] - The distance between each point of the perimeter. Set to `null` if you wish to use the `quantity` parameter instead.
* @param {integer} [quantity] - The total number of points to return. The step is then calculated based on the length of the Rectangle, divided by this value.
* @param {(array|Phaser.Geom.Point[])} [out] - An array in which the perimeter points will be stored. If not given, a new array instance is created.
*
* @return {(array|Phaser.Geom.Point[])} [description]
* @return {(array|Phaser.Geom.Point[])} An array containing the perimeter points from the Rectangle.
*/
var MarchingAnts = function (rect, step, quantity, out)
{

View file

@ -8,18 +8,18 @@ var Point = require('../point/Point');
var DegToRad = require('../../math/DegToRad');
/**
* [description]
* Returns a Point from the perimeter of a Rectangle based on the given angle.
*
* @function Phaser.Geom.Rectangle.PerimeterPoint
* @since 3.0.0
*
* @generic {Phaser.Geom.Point} O - [out,$return]
*
* @param {Phaser.Geom.Rectangle} rectangle - [description]
* @param {integer} angle - [description]
* @param {Phaser.Geom.Point} [out] - [description]
* @param {Phaser.Geom.Rectangle} rectangle - The Rectangle to get the perimeter point from.
* @param {integer} angle - The angle of the point, in degrees.
* @param {Phaser.Geom.Point} [out] - The Point object to store the position in. If not given, a new Point instance is created.
*
* @return {Phaser.Geom.Point} [description]
* @return {Phaser.Geom.Point} A Point object holding the coordinates of the Rectangle perimeter.
*/
var PerimeterPoint = function (rectangle, angle, out)
{

View file

@ -8,7 +8,8 @@ var EarCut = require('../polygon/Earcut');
var Triangle = require('./Triangle');
/**
* [description]
* Takes an array of vertex coordinates, and optionally an array of hole indices, then returns an array
* of Triangle instances, where the given vertices have been decomposed into a series of triangles.
*
* @function Phaser.Geom.Triangle.BuildFromPolygon
* @since 3.0.0
@ -17,11 +18,11 @@ var Triangle = require('./Triangle');
*
* @param {array} data - A flat array of vertex coordinates like [x0,y0, x1,y1, x2,y2, ...]
* @param {array} [holes=null] - An array of hole indices if any (e.g. [5, 8] for a 12-vertex input would mean one hole with vertices 57 and another with 811).
* @param {number} [scaleX=1] - [description]
* @param {number} [scaleY=1] - [description]
* @param {(array|Phaser.Geom.Triangle[])} [out] - [description]
* @param {number} [scaleX=1] - Horizontal scale factor to multiply the resulting points by.
* @param {number} [scaleY=1] - Vertical scale factor to multiply the resulting points by.
* @param {(array|Phaser.Geom.Triangle[])} [out] - An array to store the resulting Triangle instances in. If not provided, a new array is created.
*
* @return {(array|Phaser.Geom.Triangle[])} [description]
* @return {(array|Phaser.Geom.Triangle[])} An array of Triangle instances, where each triangle is based on the decomposed vertices data.
*/
var BuildFromPolygon = function (data, holes, scaleX, scaleY, out)
{

View file

@ -39,10 +39,10 @@ function det (m00, m01, m10, m11)
*
* @generic {Phaser.Math.Vector2} O - [out,$return]
*
* @param {Phaser.Geom.Triangle} triangle - [description]
* @param {Phaser.Math.Vector2} [out] - [description]
* @param {Phaser.Geom.Triangle} triangle - The Triangle to get the circumcenter of.
* @param {Phaser.Math.Vector2} [out] - The Vector2 object to store the position in. If not given, a new Vector2 instance is created.
*
* @return {Phaser.Math.Vector2} [description]
* @return {Phaser.Math.Vector2} A Vector2 object holding the coordinates of the circumcenter of the Triangle.
*/
var CircumCenter = function (triangle, out)
{

View file

@ -6,17 +6,16 @@
var Length = require('../line/Length');
// The 2D area of a triangle. The area value is always non-negative.
/**
* Gets the length of the perimeter of the given triangle.
* Calculated by adding together the length of each of the three sides.
*
* @function Phaser.Geom.Triangle.Perimeter
* @since 3.0.0
*
* @param {Phaser.Geom.Triangle} triangle - [description]
* @param {Phaser.Geom.Triangle} triangle - The Triangle to get the length from.
*
* @return {number} [description]
* @return {number} The length of the Triangle.
*/
var Perimeter = function (triangle)
{

View file

@ -7,17 +7,17 @@
var Point = require('../point/Point');
/**
* [description]
* Returns a random Point from within the area of the given Triangle.
*
* @function Phaser.Geom.Triangle.Random
* @since 3.0.0
*
* @generic {Phaser.Geom.Point} O - [out,$return]
*
* @param {Phaser.Geom.Triangle} triangle - [description]
* @param {Phaser.Geom.Point} [out] - [description]
* @param {Phaser.Geom.Triangle} triangle - The Triangle to get a random point from.
* @param {Phaser.Geom.Point} [out] - The Point object to store the position in. If not given, a new Point instance is created.
*
* @return {Phaser.Geom.Point} [description]
* @return {Phaser.Geom.Point} A Point object holding the coordinates of a random position within the Triangle.
*/
var Random = function (triangle, out)
{