+ rotate_onto: function(points, a, b) {
+ // Rotate points such that a (in points-space) maps onto b
+ // by crossing a and b to get a rotation axis and using
+ // angle_between to get a rotation angle.
+ var angle = this.angle_between(this.unit(a), this.unit(b));
+ if (Math.abs(angle) < 1e-15) {
+ // No siginificant rotation to perform. Bail to avoid
+ // NaNs and numerical error
+ return points;
+ }
+ var axis = this.unit(this.cross(a, b));
+ return this.rotate_about_origin(points, axis, angle);
+ },
+ rotate: function(points, center, axis, angle) { // axis must be a unit vector
+ return this.translate(
+ this.rotate_about_origin(
+ this.translate(points, this.neg(center)),
+ axis,
+ angle),
+ center);
+ },