You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Offsets the Point object by the specified amount. The value of dx is added to the original value of x to create the new x value. The value of dy is added to the original value of y to create the new y value.
90
+
* @method offset
91
+
* @param {Number} dx The amount by which to offset the horizontal coordinate, x.
92
+
* @param {Number} dy The amount by which to offset the vertical coordinate, y.
93
+
* @return {Point} This instance. Useful for chaining method calls.
94
+
* @chainable
95
+
*/
96
+
p.offset=function(dx,dy){
97
+
this.x+=dx;
98
+
this.y+=dy;
99
+
returnthis;
100
+
};
101
+
102
+
/**
103
+
* Converts a pair of polar coordinates to a Cartesian point coordinate.
104
+
* @method polar
105
+
* @param {Number} len The length coordinate of the polar pair.
106
+
* @param {Number} angle The angle, in radians, of the polar pair.
107
+
* @param {Point | Object} [pt] An object to copy the result into. If omitted a generic object with x/y properties will be returned.
108
+
* @return {Point} The new, interpolated point.
109
+
* @chainable
110
+
*/
111
+
Point.polar=function(len,angle,pt){
112
+
pt=pt||{};
113
+
pt.x=len*(Math.cos(angle));
114
+
pt.y=len*(Math.sin(angle));
115
+
returnpt;
116
+
};
117
+
118
+
/**
119
+
* Determines a point between two specified points. The parameter `f` determines where the new interpolated point is located relative to the two end points specified by parameters `pt1` and `pt2`. The closer the value of the parameter `f` is to 1.0, the closer the interpolated point is to the first point (parameter `pt1`). The closer the value of the parameter `f` is to 0, the closer the interpolated point is to the second point (parameter `pt2`).
120
+
* @method interpolate
121
+
* @param {Point | Object} pt1 The first point as a Point or generic object.
122
+
* @param {Point | Object} pt2 The second point as a Point or generic object.
123
+
* @param {Number} f The level of interpolation between the two points. Indicates where the new point will be, along the line between `pt1` and `pt2`. If `f=1`, `pt1` is returned; if `f=0`, `pt2` is returned.
124
+
* @param {Point | Object} [pt] An object to copy the result into. If omitted a generic object with x/y properties will be returned.
125
+
* @return {Point} The new, interpolated point.
126
+
* @chainable
127
+
*/
128
+
Point.interpolate=function(pt1,pt2,f,pt){
129
+
pt=pt||{};
130
+
pt.x=pt2.x+(f*(pt1.x-pt2.x));
131
+
pt.y=pt2.y+(f*(pt1.y-pt2.y));
132
+
returnpt;
133
+
};
134
+
88
135
/**
89
136
* Copies all properties from the specified point to this point.
0 commit comments