简体   繁体   中英

How to calculate two points using angle in c# xamarin forms

I have a slider for rotating the line. When the slider is slide I want to rotate the line. The slider value is set as an angle. When the page initial loading the line shape is placed as horizontal. The slider value is binded from getting the angle. I have used the below code to calculate the angle between two points.

const double Rad2Deg = 180.0 / Math.PI;
private double Angle(Point start, Point end)
{
    return Math.Atan2(start.Y - end.Y, end.X - start.X) * Rad2Deg;
}

Now I want to calculate the two points using angle. Please give me a suggestion.

Let's say we have a line beginning in a point (0,0) and ending in point (x,y). And we want to rotate it to the angle a . So, the (x,y) point will translate into (x', y') point, where

x' = x*cos(a)-y*sin(a)
y' = x*sin(a)+y*cos(a)

And the whole line will be from (0,0) to (x', y')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM