Skip to main content
GameDev.net gamedev.net
🔒 Locked

Perpendicular line

Started by BleedingBlue Dec 16, 2005 at 4:25 AM 2 replies 2.3k views
Original Post
BleedingBlue
BleedingBlue
Wow I feel like a complete newb asking but oh well:P So anyways here goes I want to find a line perpendicular to my target line lets say (23,10)-(59,100) now most things I'm seeing on the net are saying "Getting a line perpendicular to line (x, y) is simple: you can just take line (-y, x)." Where on earth did -y come from? Since -y would effectively become a really large unsigned value.
ToohrVyk
ToohrVyk
Quote:
Original post by BleedingBlue
Wow I feel like a complete newb asking but oh well:P

So anyways here goes I want to find a line perpendicular to my target line lets say (23,10)-(59,100) now most things I'm seeing on the net are saying "Getting a line perpendicular to line (x, y) is simple: you can just take line (-y, x)."
Where on earth did -y come from? Since -y would effectively become a really large unsigned value.


That is wrong. When an (x,y) notation describes a line, x and y must be points or vectors. And the assertion is obviously false when, for instance, y = (0,0) and x = (1,1), where (x,y) == (-y,x).

However, it is true that when a vector is described by its (x,y) coordinates, then the vector (-y,x) is orthogonal to the first one (check the dot product of the two). And when an (x,y) notation describes a vector, then both x and y are scalars (which have no reason at all to be unsigned).

BleedingBlue
BleedingBlue
Hmm... Ok. What I mean is that line (23,10)-(59,100) is located at pixel 23,10 to pixel 59,100. What I want is a line perpendicular to this one.

As for why x and y as unsigned its because there is no such thing as a negative pixel value...
ToohrVyk
ToohrVyk
Quote:
Original post by BleedingBlue
Hmm... Ok. What I mean is that line (23,10)-(59,100) is located at pixel 23,10 to pixel 59,100. What I want is a line perpendicular to this one.


The direction vector of your line is the vector that moves one point onto another. Here, one direction vector would be (59-23,100-10) = (36,90). A vector orthogonal to this one is (-90,36). So, if you choose a random point on the plane, a line that goes through that point and has direction (-90,36) will be perpendicular to the first one.

Quote:

As for why x and y as unsigned its because there is no such thing as a negative pixel value...


Pixels are the representation of your objects on the screen. The mathematical formulas that manipulate lines and vectors do not care about (or even know about the existence of) a given representation. They WorkTM to build new objects from previous ones. Then, you can represent these objects using whatever method you want, including turning vectors into pixels sets.

Besides, a pixel value is a color, so it is neither 'positive' nor 'negative'. If you meant a pixel coordinate, then pixel coordinates can be positive or negative, even though in some situations negative coordinates are ignored (but this is not always the case).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.