How can I draw a perpendicular on a line segment from a given point? My line segment is defined as (x1, y1), (x2, y2), If I draw a perpendicular from a point (x3,y3) and it meets to line on point (x4,y4). I want to find out this (x4,y4).
相关问题
- d3.js moving average with previous and next data v
- How to get a fixed number of evenly spaced points
- Check if a number is a perfect power of another nu
- How to determine +/- sign when calculating diagona
- Union of many (more than two) polygons without hol
相关文章
- ceil conterpart for Math.floorDiv in Java?
- why 48 bit seed in util Random class?
- Algorithm for partially filling a polygonal mesh
- Robust polygon normal calculation
- Algorithm for maximizing coverage of rectangular a
- Need help generating discrete random numbers from
- How do you create a formula that has diminishing r
- Math.Max vs Enumerable.Max
Compute the slope of the line joining points (x1,y1) and (x2,y2) as
m=(y2-y1)/(x2-x1)
Equation of the line joining (x1,y1) and (x2,y2) using point-slope form of line equation, would be
y-y2 = m(x-x2)
Slope of the line joining (x3,y3) and (x4,y4) would be
-(1/m)
Again, equation of the line joining (x3,y3) and (x4,y4) using point-slope form of line equation, would be
y-y3 = -(1/m)(x-x3)
Solve these two line equations as you solve a linear equation in two variables and the values of x and y you get would be your (x4,y4)
I hope this helps.
cheers
Mathematica introduced the function
RegionNearest[]
in version 10, 2014. This function could be used to return an answer to this question:I solved the equations for you:
Where ^2 means squared
You know both the point and the slope, so the equation for the new line is:
Since the line is perpendicular, the slope is the negative reciprocal. You now have two equations and can solve for their intersection.