09-04-2013 04:37 AM
My target is to rotate the line on my angle.
1. I have received two points: A(x1; y1) and B(x2; y2);
2. I have calculated the size of vector AB and the angle of point A:
AB = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
angleA = 44*
3. I set up the line on the coordinate plane (width = AB, height = 3px):
myLine.layoutProperties.positionX = x1;
myLine.layoutProperties.positionY = y1;
4. I have to rotate the line on the angle which has being found.
The start point of line must be the point A, the end point - point B. But, I failed =(
I try to use the rotationZ, but i dont know how to work with its propertyes PivotX and PivotY.
On default PivotX = 0 and PivotY = 0. When I try to set up PivotX = x1 and PivotY = y1 I get incorrect result.
With PivotX = 0 and PivotY = 0 I get it (myLine.rotationZ = 44):
Please, help me =)
Solved! Go to Solution.
09-04-2013 05:37 AM
P.S.: my line is the image(3px*600px), when I set up it to the coordinate plane the line has the size:
myLine.preferredHeight = 3;
myLine.preferredWidth = AB;
09-11-2013 07:58 PM
That might be happening because setting pivotX and pivotY to zero makes the rotation around the center of the element. In the case of this image that equals to its central point (300, 1.5), but not it's top left point. Try setting the pivotX to -(image.width/2), which will be: -300; and pivotY to -(image.height/2), which is -1.5; and then rotate again.
Please see more details on that topic here: