Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///@func pivot_point()
- ///@desc Given an 'origin' point, pivot another point around it.
- /// Takes in origin point coordinates, pivoting point distance (relative = true) or absolute coordinates (relative = false)
- /// Returns an [x,y] array with the pivoted point coordinates
- ///
- ///@param origin_x Origin X
- ///@param origin_y Origin Y
- ///@param point_x Point X distance or X coordinate
- ///@param point_y Point Y distance or Y coordinate
- ///@param relative [Boolean] Point is passed as distance from origin (true) or absolute coordinates (false)
- ///@param pivot_angle The angle at which the point is to be pivoted
- var _origin_x = argument0;
- var _origin_y = argument1;
- var _point_x = argument2;
- var _point_y = argument3;
- var _relative = argument4;
- var _pivot_angle= argument5;
- //Find the origin-to-point angular distance
- var _dist = _relative ? point_distance(0, 0, _point_x, _point_y) : point_distance(_origin_x, _origin_y, _point_x, _point_y);
- //Find the origin-to-point angle, plus pivot
- var _angle = _relative ? point_direction(0, 0, _point_x, _point_y) : point_direction(_origin_x, _origin_y, _point_x, _point_y)
- _angle += _pivot_angle;
- var _x = _origin_x + lengthdir_x(_dist, _angle); //Get the pivoted origin-to-point x distance
- var _y = _origin_y + lengthdir_y(_dist, _angle); //Get the pivoted origin-to-point y distance
- return [_x, _y]; //return coordinates as an array
Advertisement
Add Comment
Please, Sign In to add comment