АвтоАвтоматизацияАрхитектураАстрономияАудитБиологияБухгалтерияВоенное делоГенетикаГеографияГеологияГосударствоДомДругоеЖурналистика и СМИИзобретательствоИностранные языкиИнформатикаИскусствоИсторияКомпьютерыКулинарияКультураЛексикологияЛитератураЛогикаМаркетингМатематикаМашиностроениеМедицинаМенеджментМеталлы и СваркаМеханикаМузыкаНаселениеОбразованиеОхрана безопасности жизниОхрана ТрудаПедагогикаПолитикаПравоПриборостроениеПрограммированиеПроизводствоПромышленностьПсихологияРадиоРегилияСвязьСоциологияСпортСтандартизацияСтроительствоТехнологииТорговляТуризмФизикаФизиологияФилософияФинансыХимияХозяйствоЦеннообразованиеЧерчениеЭкологияЭконометрикаЭкономикаЭлектроникаЮриспунденкция

Simplest Line Drawing Algorithm

Читайте также:
  1. Boundary-Fill Algorithm
  2. Bresenham's Circle Algorithm
  3. Bresenham's Line Algorithm
  4. Computers and algorithms
  5. Cyrus–Beck Algorithm
  6. Drawing a Closed Cardinal Spline
  7. Drawing a Polygon
  8. Drawing and Manipulating Shapes and Images
  9. Liang–Barsky Algorithm
  10. Line Drawing Algorithms
  11. Scan-Line Polygon Fill Algorithm

One method of drawing line segment is to solve the differential equation describing this process. For a straight line, we have

(4.1)

The solution is represented as:

(4.2)

where x1, y1, x2, y2 are the ends of the drawing segment and yi is the initial value for the next step along the segment. Here is the simplest algorithm that runs in the first quadrant:

dx = x2 - x1

dy = y2 - y1

for x from x1 to x2 {

y = y1 + (dy)*(x - x1)/(dx)

plot(x, round(y))

}

It is assumed here that the points have already been ordered so that x2 > x1. This algorithm works just fine when dx > = dy (i.e., slope is less than or equal to 1), but if dx < dy (i.e., slope greater than 1), the line becomes quite sparse with lots of gaps, and in the limiting case of dx = 0, only a single point is plotted.

The simplest line drawing algorithm is inefficient and thus, slows on a digital computer. Its inefficiency stems from the number of operations and the use of floating-point calculations.


1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 |

Поиск по сайту:



Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав. Студалл.Орг (0.003 сек.)