using
System;
class
GFG
{
public
static
void
Main(
string
[] args)
{
Point P =
new
Point(4.0, 3.0);
Point Q =
new
Point(2.0, 2.0);
double
theta = Math.PI / 2;
Point P_rotated = Rotate(P, Q, theta);
Console.Write(
"The point P on rotating 90 degrees anti-clockwise about Q becomes: "
);
DisplayPoint(P_rotated);
}
static
void
DisplayPoint(Point P)
{
Console.WriteLine(
"("
+ P.x +
", "
+ P.y +
")"
);
}
static
Point Rotate(Point P, Point Q,
double
theta)
{
return
(P.Subtract(Q)).Multiply(
new
Point(Math.Cos(theta), Math.Sin(theta))).Add(Q);
}
class
Point
{
public
double
x;
public
double
y;
public
Point(
double
x,
double
y)
{
this
.x = x;
this
.y = y;
}
public
Point Add(Point b)
{
return
new
Point(x + b.x, y + b.y);
}
public
Point Subtract(Point b)
{
return
new
Point(x - b.x, y - b.y);
}
public
Point Multiply(Point b)
{
return
new
Point(x * b.x - y * b.y, x * b.y + y * b.x);
}
public
Point Multiply(
double
b)
{
return
new
Point(x * b, y * b);
}
public
Point Conjugate()
{
return
new
Point(x, -y);
}
public
double
Mod()
{
return
Math.Sqrt(x * x + y * y);
}
public
double
Arg()
{
return
Math.Atan2(y, x);
}
public
Point Polar(
double
r,
double
theta)
{
return
new
Point(r * Math.Cos(theta), r * Math.Sin(theta));
}
}
}