Closed samreid closed 7 years ago
Moving it to dot sounds good (Node's rotateAround can't be used here it seems).
Presumably:
function( origin, angle )
function( origin, angle )
For higher-dimension cases (Vector3/Vector4), we'd presumably handle rotating around an axis, with a different name and handling (don't need right now).
Implementation looks good (already optimized).
Let me know if I should add this, or if you'd like to.
I'm happy to proceed but wanted to briefly discuss the naming discrepancy between Node.rotateAround and the proposed method names for Vector2. Is it desirable for them to differ? Should one be changed so they match up?
Why did you say:
Vector2 method rotateAboutPoint/rotateAroundPoint?
Did you mean rotateAbout/rotateAboutPoint, where the first one would take x,y and the 2nd would take vector2?
Did you mean rotateAbout/rotateAboutPoint, where the first one would take x,y and the 2nd would take vector2?
Just meant I wasn't sure whether 'about' or 'around' should be used, ideally it would match Node's naming also.
Did you mean rotateAbout/rotateAboutPoint, where the first one would take x,y and the 2nd would take vector2?
It may be desirable to have multiple independent functions for this?
inherit( Object, Vector2, {
// ...
rotateAboutXY: function( x, y, angle ) { ... mutable logic... },
rotateAboutPoint: function( point, angle ) { return this.rotateAboutXY( point.x, point.y, angle ); },
rotatedAboutXY: function( x, y, angle ) { ... immutable logic ... },
rotatedAboutPoint: function( point, angle ) { return this.rotatedAboutXY( point.x, point.y, angle ); }
} );
Rough draft committed above, @jonathanolson would you mind spot checking it to see if I've forgotten anything?
Some quick notes (I'd handle but dot is getting checked out to many other branches right now):
@param {Vector2} angle
should be number on rotatedAboutPoint@returns
instead of @return
Thanks for the review @jonathanolson, I think I addressed the issues in the above 2 commits. Can you please double check?
Looks good to me, feel free to close if that's everything you needed.
CCK has this code in LightBulb.js
@jonathanolson do you think it is appropriate to move this function to dot? If so, what should the exact signature be?