Constraining angles

06272016, 09:39 PM
Post: #1




Constraining angles
In creating some tools, I was pleased with the simplicity and elegance of calculating the angle between two points with an expression such as
Code: artAngle = (gxg.startPt^gxg.endPt); It plotted the points and angles exactly as I'd expect. Then I experimented with the angle constrain functions and am completely baffled. Code: p1 = gxg.mouseDownPt; When I put the points p1 and p2 into vector, then into a path and drag the mouse, the resultant line and angle change as I drag, but with some seemingly random relationship to the point where I'm dragging in terms of either angle or distance, with or without the "nearest45" option. It seems to have a mind of its own, regardless of which quadrant I'm in. I'd really appreciate any tips on this. In most instances, I just want to flip an object either north or south of the primary angle, or in some cases eastwest as well, i.e., snap to either 1/4 or 1/8 radian to orient my new art object in terms of direction (90 or 180 degree increments from the artAngle), reversing it to be right or lefthanded as needed. Any guidance would be very much appreciated!  rj 

06282016, 05:30 AM
Post: #2




RE: Constraining angles
Oops, I meant 1/4 or 1/8 turn, not radians. The function works much better if I use
Code: p2=p1.move(dragDist,artAngle); I found that the *.LengthAngle function measures from the artboard origin, not the original point. I must have been confused by the ^ angle operator notes re: origin, but functioning from one point to another. Code: \brief Gets the angle of the vector (this, rhs_), if this were moved to the origin Now I just need to experiment with the constrain functions. I do, of course, have my own functions from previous plugins, but I believe it's a safe bet that CORE's are better. 

06282016, 05:36 PM
Post: #3




RE: Constraining angles
I had an opportunity to test the behavior of the constrain functions once the tool had a working "rubberband" drag line based on ArtboardPoint.move(distance,angle). Is that the preferred method?
Now it makes sense; One Angle option constrains every 45 degrees per the usual behavior when pressing the shift key, and the others flip the line 180 degrees depending on whether you're left, right, above, or below the start point. I guess I was expecting additional options similar to some constrain functions that I'd written, e.g., that could operate on any axis, not just horizontal and vertical. Maybe all that is there, but I just don't know how to access it (the only point math function I understand is multiplying a point by zero to get to the artboard origin of (0,0). I apologize for my ramblings and for wasting some perfectly good anxiety. Perhaps another user can benefit from this thread sometime later. 

07022016, 12:33 PM
Post: #4




RE: Constraining angles
Looks like you've got it pretty much figured out. We don't offer arbitrary angle constraints, but you could accomplish it fairly easily by first subtracting the desired angle offset (e.g. 30°), performing the constraint to e.g. 45°, then adding the same desired angle offset (e.g. 30°).


« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)