GithubHelp home page GithubHelp logo

Implementasi Algoritma DDA

Dalam project ini menggunakan Aplikasi CodeBlock sebagai tempat penulisan codingnya. agar dapat menjalankan Project ini Codeblocknya harus sudah di include glut.h di MINGW -nya. untuk cara include glut.h dapat dilihat di video ini : https://youtu.be/pak-Z6uQjAQ.

Algoritma DDA adalah suatu algoritma yang digunakan menggambar garis. Garis yang dapat digambar adalah garis vertikal,horisontal, atau miring 45 derajat. Saat ada 1 derajat perubahan maka akan menajadi seperti tangga Kelebihan Algoritma ini dapat menggambar garis ke segala arah dengan code yang sedikit dan logika yang mudah. Tetapi Algorima ini mempunyai kelemahan yaitu menggunakan pembualatan sehingga kurang presisi.

Project ini menggunakan user input dalam menentukan titik awal (x1,y1) dan titik Akhirnya (x2,y2), dengan catatan semua nilai x1,y1,x2,y2 harus positif.

Output program ini berupa garis yang digambar di window baru dan panjangnya sesuai dengan input.

Algoritma DDA yang digunakan :

Int dx = x2-x1; Int dy = y2-y1; Int steps,k,x1,y1,x2,y2; Float x_inc, y_inc; Float x = x1; Float y = y1;

If (abs(dx)>abs(dy)) steps = abs(dx) else steps = abs(dy);

X_inc = dx/(float)steps; Y_inc = dy/(float)steps;

setPixel(Round(x),Round(y));

For(k=0;k<steps;k++) { x+=x_inc; y+=y_inc; setPixel(Round(x),Round(y));

}

faulza's Projects

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.