how to move point along line with specific direction
Show older comments
Hi I have the folowing image:

As seen in the image, the points are randomly distributed in the x-y plane.Each point has its own x any y local axis. I need to move the red point a long its x-axis, how I can do that? I know the coordinates of the red point and the direction of x-axis (the angle in radian).here the code for drawing the points and the directions for each point: function [ h, xEnd, yEnd ] = draw_arena( x, y, theta, a, b )
L = 2; %# Length of arrow
s = 0.2; %# stretch o the arrow
xEnd = L*cos(theta); %# X component of the x_axis arrow
yEnd = L*sin(theta); %# Y component of arrow of the x_axis
hold on; %# Add subsequent plots to the current axes
axis ([a b a b]) %# Set axis limits
axis equal; %# Make tick increments of each axis equal
for i = 1:length(x)
h(i) = plot(x(i),y(i),'o','MarkerEdgeColor','b','MarkerFaceColor','b','Markersize',20); %# Plot the points
end
x_axis = quiver(x,y,xEnd,yEnd,s,'color',[1 1 0]); %# plot yellow x-axis
text((x+xEnd),(y+yEnd),'x')
x_End = L*cos(theta+ pi/2); %# X component of the y_axis arrow end
y_End = L*sin(theta + pi/2); %# Y component of arrow of the y_axis end
y_axis=quiver(x,y,x_End,y_End,s,'color',[1 0 1]); %# plot purple y_axis
text((x+x_End),(y+y_End),'y')
end
I would appreciate your help I would like also to rotate the x-axis for the blue points, so that they align with the red point x-axis?I required to find the coordinates of the blue points in term of red point coordinates I know the distance between points and have the angle between each point x-axis and the standard (common) x-axis. How I can do that rotation? how I can find the angle between each point x-axis and the red point x-axis and the points value in using the red point coordinates? Thanks for your help
1 Comment
Eman hasan
on 25 Aug 2015
Edited: Eman hasan
on 25 Aug 2015
Answers (1)
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!