Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
create line given slope and a point

Subject: create line given slope and a point

From: Aidy

Date: 23 Jan, 2011 00:40:04

Message: 1 of 4

hello folks,

I am faced with a problem, not particularly Matlab related but asking for your help .

On an image I have a pixel location(u,v).

Starting at this point, I want to find a point 20 pixels away from it at a slope of 15.

So basically I want to create a line given starting point, the slope, and the length I wish to increase by.

Please, anyone help if you can.

all the best,
aidy

Subject: create line given slope and a point

From: Aidy

Date: 23 Jan, 2011 01:13:04

Message: 2 of 4

Hi guys, just to make a correction:

I know the normal direction vector of the line and NOT the slope.

--aidy

Subject: create line given slope and a point

From: Paulo Silva

Date: 23 Jan, 2011 01:39:04

Message: 3 of 4

"Aidy" wrote in message <ihfvav$sjb$1@fred.mathworks.com>...
> Hi guys, just to make a correction:
>
> I know the normal direction vector of the line and NOT the slope.
>
> --aidy

I don't know much about what is slope or normal direction vector so I'm going to use the variable s as the angle of the line in radians, you can make the conversion later

function [x y]=linePJ(x1,y1,l,s)
%x1 is you u and y1 is your v
x=l*cos(s)+x1
y=l*sin(s)+y1
end

%Data for you to test the function
x1=0
y1=0
l=1
s=pi/2
[x y]=linePJ(x1,y1,l,s)
clf
line([x x1],[y y1])
hold on
plot(x,y,'x')
plot(x1,y1,'o')

Subject: create line given slope and a point

From: Aidy

Date: 23 Jan, 2011 03:34:04

Message: 4 of 4

thank you paulo

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us