Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Normalized perpendicular #18

Answered by DerYeger
bstro asked this question in Q&A
Sep 1, 2022 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Hi, this shouldn't be too difficult!

You could use this StackOverflow answer, or use Vecti's methods as seen below:

const b = new Vector(x1, y1);
const c = new Vector(x2, y2);
const aToB = B.subtract(A);

const orth = aToB.rotateByDegrees(90).normalize()

// Multiple by (-1) * 6 / 2 to get C, 6 / 2 to get D
const c = b.add(orth.multiply(-3))
const d = b.add(orth.multiply(3))

Let me know if this works, I wrote it off the top of my head.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@bstro
Comment options

@DerYeger
Comment options

Answer selected by bstro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants