計算機圖形學畫線_在計算機圖形學中直接使用線方程

計算機圖形學畫線

計算機圖形學| 直接使用線方程 (Computer Graphics | Direct Use of Line Equation)

The standard line equation, as we all know is used for drawing a line. It is given by: y = mx + c.

眾所周知,標準線方程式用于繪制線。 由下式給出: y = mx + c

We are discussing here in 2D so we all know that there are 2 axes: x and y. Both of the axes are required to give the equation of any 2D shape. The line is a straight path joining 2 points in the x-y plane. If both the points are given then we can find the equation of a line.

我們在這里以2D進行討論,所以我們都知道有2個軸: xy 。 需要兩個軸都可以給出任何2D形狀的方程。 該線是連接xy平面中2個點的直線路徑。 如果兩個點都給出,那么我們可以找到一條線的方程。

直線的斜率 (The slope of a line)

The slope of a line defines the direction of a line. Its value is equal to the ratio of the difference of y coordinates and the difference. Assume that the two points are X( x1,y1 ) and Y( x2,y2 ). Its slope, 'm' will be: m = (y2 - y1) / (x2 - x1).

線的斜率定義了線的方向。 它的值等于y坐標差與差之比。 假設這兩個點是X(x1,y1)Y(x2,y2) 。 它的斜率'm'將是: m =(y2-y1)/(x2-x1)

線描算法的性質 (Properties of Line Drawing Algorithm)

The following are the properties that a line must hold in any line drawing algorithm,

以下是任何線圖繪制算法中線必須具有的屬性,

  1. Line must be straight

    線必須是直的

  2. Line must terminate accurately

    線路必須準確終止

  3. Line must have constant density

    線必須具有恒定的密度

  4. Density must be independent of its length

    密度必須與長度無關

  5. Line must be drawn very fast

    線必須畫得很快

線描算法 (Line Drawing Algorithms)

There are some set of rules and steps which help draw a line. These algorithms are given below,

有一些規則和步驟可以幫助您劃清界限。 這些算法如下:

  1. Direct Use of line equation

    直接使用線方程

  2. DDA (Digital Differential Analyzer)

    DDA(數字差分分析儀)

  3. Bresenham's Algorithm

    布雷森納姆算法

直接使用線方程 (Direct use of Line Equation)

This is the simplest form of drawing a line. We all know that the equation of the line is y = mx + c. Here m is slope and c is the length from origin to the point where the line cuts y-axis. In this method, we will be having the start and endpoint of the line and by the help of that points, we'll calculate the other points which lie on the line. We have to find the slope of the line by using the given points.

這是畫線的最簡單形式。 我們都知道直線的方程是y = mx + c 。 這里的m是斜率, c是從原點到直線切割y軸的點的長度。 在這種方法中,我們將獲得直線的起點和終點,并借助這些點,計算出直線上的其他點。 我們必須使用給定的點找到線的斜率。

We'll understand this better with the help of an example,

我們將通過一個示例來更好地理解這一點,

Example:

例:

We have given two points X and Y. The coordinates of X are (0, 0) and the coordinates of Y are (5, 15). The slope of the line will be,

我們給出了XY兩點。 X的坐標為(0,0)Y的坐標為(5,15) 。 線的斜率是

    m = (15 - 0) / (5-0)
m = 3

We have the slope of the line. Now let us put the slope in the line equation.

我們有直線的斜率。 現在讓我們將斜率放在線方程中。

    y = 3x + c

Origin point is (0,0). So,

原點是(0,0)。 所以,

    c = 0

Putting c=0 in the above equation.

將c = 0放在上式中。

    y = 3x

Now we will calculate the intermediate points.

現在我們將計算中間點。

    Let x = 1 ? y = 3 x 1 ? y = 3
Let x = 2 ? y = 3 x 2 ? y = 6
Let x = 3 ? y = 3 x 3 ? y = 9
Let x = 4 ? y = 3 x 4 ? y = 12
Let x = 5 ? y = 3 x 5 ? y = 15

We got the intermediate points which are, (1, 3), (2, 6), (3, 9), (4, 12) and finally (5, 15)

我們得到的中間點是(1、3),(2、6),(3、9),(4、12),最后是(5、15)

Now we'll plot these points on the graph.

現在,我們將這些點繪制在圖形上。

Direct Use of Line Equation

Hence, we have plotted the points that lie between the given points through the standard line equation. By doing so with a very small gap between these pints will give us the entire line.

因此,我們通過標準線方程式繪制了位于給定點之間的點。 這樣,這些品脫之間的間隙很小,就可以給我們整條生產線。

翻譯自: https://www.includehelp.com/computer-graphics/direct-use-of-line-equation.aspx

計算機圖形學畫線

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/378941.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/378941.shtml
英文地址,請注明出處:http://en.pswp.cn/news/378941.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Request.ServerVariables (server environment variable)

參數 服務器環境變量指定要檢索的服務器環境變量名。可以使用下面列出的值。 變量說明ALL_HTTP客戶端發送的所有 HTTP 標題文件。ALL_RAW檢索未處理表格中所有的標題。ALL_RAW 和 ALL_HTTP 不同,ALL_HTTP 在標題文件名前面放置 HTTP_ prefix,并且標題名稱…

c/c++ 編程試題

c/c 編程試題 帶*號為選作題&#xff0c;給出代碼截屏和編譯運算結果截屏 1.編程:選取M個最大的數 編程實現從N個無序數中選取M個最大的數(0 < M < N ) 思路&#xff1a;通過冒泡排序或者選擇排序對N個數進行遞減排序&#xff0c;然后輸入前M個數即可。這里我想到的是通…

Java String startsWith()方法與示例

字符串startsWith()方法 (String startsWith() Method) startsWith() method is a String class method, it is used to check whether a given string starts with specific character sequences or not. startsWith()方法是一個String類方法&#xff0c;用于檢查給定的字符串…

mysql inception web_基于Inception搭建MySQL SQL審核平臺Yearing

Inception1. Inceptionj簡介Inception是一款針對MySQL的SQL語句審核自動化運維工具。使用Inception&#xff0c;將會給DBA帶來更大的便利性&#xff0c;將DBA從繁冗的工作中解放出來&#xff0c;做更多的自動化工作&#xff0c;或者從架構方面研究如何更大程度地保證數據庫的高…

C---日常練習

若有以下定義語句&#xff1a;int a5;printf("%d\n",a);則輸出結果是&#xff08;&#xff09; 解析&#xff1a;a 即先使用再自增&#xff0c;a的初始值即為5&#xff0c;則先使用&#xff0c;輸出結果為5 舉個例子&#xff1a; int a5,b; ba;//等價于 ba;aa1 prin…

VS2010 運行庫設置

如下圖所示&#xff0c;當在一個EXE工程中調用lib或dll時&#xff0c;2個工程的下面選項一定要一致&#xff0c;否則會導致exe工程編譯不過。 原則&#xff1a; Debug下&#xff0c;默認是MTd&#xff1b; Release下&#xff0c;默認是MT。 轉載于:https://www.cnblogs.com/lgh…

算法中的Strassen矩陣乘法

Introduction 介紹 Strassen in 1969 which gives an overview that how we can find the multiplication of two 2*2 dimension matrix by the brute-force algorithm. But by using divide and conquer technique the overall complexity for multiplication two matrices i…

零拷貝、mmap、sendfile

目錄零拷貝mmapsendFile總結零拷貝 要了解零拷貝&#xff0c;首先得先了解一下傳統 IO 的執行流程&#xff0c;這里舉個例子&#xff0c;通過傳統的 IO 進行網絡傳輸來傳輸一個文件。 先上一張圖&#xff0c;這張圖就代表了傳統 IO 傳輸文件的流程。 讀取文件的時候&#xf…

網頁服務器和mysql服務器_實現Web服務器之間使用同一個MYSQL和相同的網頁配置文件的方法...

實現Web服務器之間使用同一個MYSQL和相同的網頁配置文件的方法發布時間&#xff1a;2020-04-15 16:42:41來源&#xff1a;億速云閱讀&#xff1a;133作者&#xff1a;三月欄目&#xff1a;數據庫億速云負載均衡(Cloud Load Balancer)是對多臺云服務器進行流量分發的服務。億速云…

傳128GB版iPad4售價為799/929美元

外媒9to5mac報道&#xff0c;蘋果將推出一款升級版iPad4&#xff0c;外觀和iPad 4相同&#xff0c;還是黑白兩色的&#xff0c;只加入了新的SKU。 據報道&#xff0c;這款升級版iPad4還有128GB版&#xff0c;隨著這條消息傳出&#xff0c;不久關于128GB版iPad4的售價信息也傳出…

(西工程-金花)小米路由器連接哆點設置WiFi保姆式教程

小米路由器連接電源,用根網線一端插入寢室的網口處,另一端插入小米路由器的WAN口手機或者電腦連接WiFi,我這里是通過手機瀏覽器打開192.168.31.1進入無線路由器管理頁面進行配置小米路由器&#xff0c;配置WiFi的一些基本參數,例如:WiFi名稱,密碼之類的信息 進入無線路由器管理…

基于MINA框架快速開發網絡應用程序

1&#xff0e;MINA框架簡介 Netty、Mina、Cindy都是不錯的NIO開源框架&#xff0c;后兩者都是在Netty的基礎上演化出來的。MINA(Multipurpose Infrastructure for Network Applications)是用于開發高性能和高可用性的網絡應用程序的基礎框架。通過使用MINA框架可以可以省下處理…

Python中@staticmethod和@classmethod之間的區別

classmethod裝飾器 (The classmethod Decorator) The classmethod decorator is an inbuilt function decorator that gets evaluated after the function is defined. The result of the evaluation shadows the function definition. The classmethods first argument is alw…

go 聲明二維數組_一篇文章了解Go語言中數組Arrays的使用內幕

概述與其他編程語言類似&#xff0c;Go語言也有數組array。Go語言中&#xff0c;數組的行為和其他語言沒有什么不同.Go語言中還有一個叫做切片slice的東西&#xff0c;它就像是對數組的引用。在本文中&#xff0c;我們將只研究數組。定義數組是同一類型元素的連續集合&#xff…

ffmpeg 使用ffplay 進行 hls 拉流 分析 1

ffmpeg 使用 ffplay 進行 hls 拉流 分析 1 從使用ffplay 調用 http://192.168.1.100:8080/live/livestream.m3u8 開始&#xff0c;進入到ffmpeg 的分析使用的協議選擇相應的解復用器的步驟。 其他協議或者文件方式的使用ffplay也是這個步驟流程的。 目錄&#xff1a;一、流程圖…

搜狗輸入法輸出特殊符號快捷鍵

https://www.petefreitag.com/cheatsheets/ascii-codes/ 參考上個編碼網站大全 詳細步驟為&#xff1a;alt長按 &#xff0b; 編碼數字 例如&#xff1a;平方的編碼為178-----長按alt178 即可&#xff0c;178是數字一個一個挨個按即可 常用的特殊符號如下&#xff1a; 平方&…

echo 12345678 | base64 產生的結果跟12345678真正的base64編碼不對

echo "12345678" | base64 產生的結果跟"12345678"真正的base64編碼不對 弄了好久才搞清楚&#xff0c;echo 命令是帶換行符的&#xff0c;改成echo -n "12345678" | base64就沒問題了轉載于:https://www.cnblogs.com/senix/archive/2013/01/30/…

[BuildRelease Management]CC.NET架構

一 CC.NET的操作流程 1) 等待Trigger的喚醒&#xff1b; 2&#xff09;從Source Control System查詢上次build以后的修改列表&#xff1b; 3&#xff09;如果任何修改被發現或是Trigger觸發類型為 force the build &#xff1a; 3.1&#xff09;為build產生一個label number&a…

python 入門到實踐期末考試常出現的考試內容_Python編程入門到實踐—列表篇(一)...

一、列表是什么&#xff1f;列表由一系列按特定順序排列的元素組成。可以創建包含字母表中所有字母、數字0-9或所有家庭成員姓名的列表&#xff1b;也可以將任何東西加入列表中&#xff0c;其中的元素之間可以沒有任何關系。列表通常包含多個元素&#xff0c;給列表指定一個表示…

c#中將集合寫入文本_在C#中將記錄插入MySQL數據庫

c#中將集合寫入文本In the last tutorial (how to connect with MySQL database in C#?), we learned about making the connection with MySQL database in C#. Here, in this tutorial, we will learn how to insert the records in MySQL database in C#? 在上一教程( 如何…