# How to build a perpendicular of a certain length for a segment rotated to some angle?

How to build a perpendicular of a certain length for a segment rotated to some angle?

I’m particularly interested in the coordinates of point C

You can use the concept of vectors to get the perpendicular line.Referring the following website Perpendicular Vector I have made a method that returns the coordinates of C.

``````/*
This funcion return the coordinates of C
start = Start point of the line segment (A in your case)
end = end point of the line segment (B)
origin = from which point you wan to draw a perpendicular (A in your case)
length = length of the perpendicular
*/
private Vector2 perpendicularVector2(Vector2 start, Vector2 end,Vector2 origin,int length)
{
Vector2 direction = (end - start).normalized;
Vector2 perpendicularDirection = new Vector2(-1*direction.y,direction.x).normalized;
Vector2 requiredLengthVector2 = perpendicularDirection * length;
Vector2 resulVector2 =new Vector2( requiredLengthVector2.x + origin.x , requiredLengthVector2.y+origin.y);
return resulVector2;
}
``````