Рисование перпендикулярных линий между двумя путями

589
Kivanc Basak

Я архитектор, работающий на древних объектах архитектурной документации. Сейчас я пытаюсь сделать олдскульный ландшафтный рисунок, который включает кривые высоты. (Линии контура)

Поэтому для этого я пытаюсь нарисовать перпендикулярные линии, расположенные вдоль одной линии, начиная с нее и заканчивая следующей. что, мне нужно сделать это по крайней мере 750 строк.

Итак, чтобы подвести итог, я хочу заполнить промежуток между двумя строками линиями, которые перпендикулярны пути, с которого они начинаются и заканчиваются на следующей.

0
У вас есть вопрос? Phlamajam 8 лет назад 1
как я могу нарисовать эти линии? Kivanc Basak 8 лет назад 0
Я думаю, что этот вопрос здесь не по теме. http://superuser.com/help/on-topic Вы получите больше ответов, если спросите в правильном месте. Katu 8 лет назад 0

1 ответ на вопрос

1
John Smith

If I got your question right, you want to draw something like a stairs. I will assume that one of the lines has an equation

a x + b y + c = 0 

with nonzero a and b (special cases a=0 or b=0 are trivial). I will also assume that a^2+b^2=1 (if not, just divide the equation by 1/sqrt(a^2+b^2)).

Then if have the lengths of your lines L, and the coordinate of starting point is (x0,y0), then coordinates of other points, where perpendicular lines start are

(x_i, y_i) = ( x0 + (b L i)/(N-1), y0 - (a L i)/(N-1) ) 

where i runs fro 0 to N-1, and N is the number of points, that you need for your staircase.

Note: if points will go in the wrong direction, use the opposite sign

(x_i, y_i) = ( x0 - (b L i)/(N-1), y0 + (a L i)/(N-1) ) 

After you have points, where the perpendicular lines start, the parametric equations for each perpendicular line is

x_i(t) = x_i + a t D, y_i(t) = y_i + b t D 

where t changes from 0 to 1 and D is the distance between your parallel lines.

Note: if perpendicular lines go to the wrong direction, change sign

x_i(t) = x_i - a t D, y_i(t) = y_i - b t D 

That is more or less it)

and what if you are dealing with a wavy stair case instead of a circular or straight one? Forward Ed 5 лет назад 0

Похожие вопросы