plot points on a line perpendicular to a directed vector

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By duronrulez

Example image: https://imgur.com/KT14qbz

I have the values of A, B,C known i want to be able to place points like D, E on the perpendicular.

Essentially im trying to place points on that perpendicular that are X away from A.

What would the formula for those be?

godot perpendicular help

:bust_in_silhouette: Reply From: jgodfrey

There’s any number of ways to get a rotated vector. Here’s one…

var dist = 2
var v1 = Vector2(10, 10)
var v2 = v1.rotated(90 * PI / 180).normalized() * dist
var v3 = v1.rotated(-90 * PI / 180).normalized() * dist
print(v1)
print(v2)
print(v3)

There, dist is the distance along the rotated vectors to project your points (X away from A in your description).

v1 is the original vector (AB in your description)
v2 and v3 are the rotated (+90 and -90 degrees) vectors, of length dist