How to get perpendicular vectors given a line segm


How to get point A, B , C, and D?

if AB and CD are perpendicular to p0p1.

Assume p0A, p0B, p1C, and p1D have normalized length


The direction of the line is given by d = normalize(p1 - p0). To calculate a perpendicular vector we can use the cross product with (0, 0, 1). Which results in:

d_left = (-d.y, d.x) d_right = (d.y, -d.x)

You haven't said how your coordinate system is aligned, so d_left might become d_right and vice versa.

You then get the desired points with:

A = p0 + d_left B = p0 + d_right C = p1 + d_left D = p1 + d_right


Suppose rotate(p,d) is a operator to rotate p vector d angle.

Then if the inclination of p0p1 with positive x-axis is x. Then,

A = p0 + rotate(p1-p0,pi/2)/|p1-p0|
B = p0 + rotate(p1-p0,-pi/2)/|p1-p0|
C = p1 + rotate(p1-p0,pi/2)/|p1-p0|
D = p1 + rotate(p1-p0,-pi/2)/|p1-p0|


  • How to get perpendicular vectors given a line segm
  • ReportViewer “Export to Excel” adds decimal to percentage values. How can I override this?
  • SQL String format for Full Text Search in C# Entity Framework
  • RVM on Ubuntu Troubles
  • How to load time zone data into Moment-timezone.js
  • Slow loading rails environment
  • DB pull from heroku fails with Encoding::CompatibilityError
  • Joining a table to itself in Oracle
  • Algorithm that Generates Unique Serial Number for Each English Word
  • Cannot inject $ionicHistory into my angularjs controller
  • Why do I get an error installing bson_ext?
  • Why are there differences in psych::principal between “Varimax” and “varimax”?
  • The dimensions in hist for numpy.histogram with density = True
  • Extracting data from a string where the data structure is embedded in the string itself
  • sort decimal in php or mysql
  • d3.js - Tree Layout - How can I flip it?
  • Angular DatePicker - Multiple directives > [datepicker, datepicker]
  • Why is YAML.load returning the wrong numeric value?
  • Stanford-parser in Ruby does not create Preprocesser
  • SQL Need a query that returns every field that contains a specified letter
  • How to normalize a database schema
  • How to change the margins of a correlation matrix plot
  • how to calculate distance between two points in google maps?
  • Put percent labels next to legend instead of in the slice
  • HABTM associations in Rails : collecting and counting the categories of a model's children
  • Making a URL W3C valid AND work in Ajax Request
  • Aligning image on right side of title on UIButton with imageEdgeInsets and titleEdgeInsets
  • Initialization section of the package
  • Guava how to copy all files from one directory to another
  • Is there a package like bigmemory in R that can deal with large list objects?
  • How to determine if there are bytes available to be read from boost:asio:serial_port
  • Avoid links criss cross / overlap in d3.js using force layout
  • MongoDB in PHP using aggregate to group by _id is null not working
  • Initializer list vs. initialization method
  • Using $this when not in object context
  • How do I fake an specific browser client when using Java's Net library?
  • How reduce the height of an mschart by breaking up the y-axis
  • Perl system calls when running as another user using sudo
  • XCode can't find symbols for a specific iOS library/framework project
  • Getting Messege Twice Using IMvxMessenger