A
A
Alex2019-11-24 05:42:21
JavaScript
Alex, 2019-11-24 05:42:21

How to draw a ray with a function based on two points and calculate the intersection of the perpendicular from the third point on the ray?

There are three points with coordinates:

var pos1 = {x:(число), y:(число)},
      pos2 = {x:(число), y:(число)},
      pos3 = {x:(число), y:(число)};

How to create a function that will describe a ray based on two points pos1 and pos2 , and return the point where the perpendicular from the point pos3 lies on this ray. I would be grateful if someone fumbles in geometry and tells me how to do this :)
I threw in such a gif for visual understanding: ( on the gif, there is an error rerurn -> return )FyWo1.gif

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
RAX7, 2019-11-24
@alexjet73


https://www.mathsisfun.com/algebra/line-parallel-p...

G
Grigory Boev, 2019-11-24
@ProgrammerForever

1) Calculate the equation of a straight line passing through points 1 and 2
, we express y through x, we get the equation
and express y through x, we get
y = a₂x + b₂
3) There are equations of lines - you need find the intersection, i.e. solve a system of two linear equations. There are a lot of methods here - from simple transformations to matrices. because we have equations in the form y=f(x) , then we can do this:

приравниваем уравнения 1 и 2, избавляемся тем самым от y
вычисляем x
подставляем найденное x в любое уравнение

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question