Code Monkey home page Code Monkey logo

computer-graphics-algorithms's Introduction

Computer Graphics Algorithms in java

This repository contains most of my lab works of Computer Graphics Course(CSE423). The codework can be found in the src directory

Contents:

  • DDA Line Drawing Algorithm
  • Bresenham Line Drawing Algorithm
  • Mid Point Line Drawing Algorithm
  • Cohen Sutherland Line Clipping Algorithm
  • Eight Way Symmetry Circle Drawing Algorithm
  • Drawing Square using DDA
  • Drawing Square using Mid Point
  • Drawing Star using Mid Point
  • Drawing WoW emo using Circle

Dependencies:

The following jars are used in this codework and they are required:

  • jogl-all.jar
  • jogl-all-natives-{linux or windows}.jar
  • glugen-rt.jar
  • glugen-rt-natives-{linux or windows}.jar

Libraries are available at lib directory

How to use:

  1. This repository is an IntelliJ IDEA project.
    • Thus you can simply clone or download the repository and open with IntelliJ IDEA
  2. You can use the code seperately from the source directory

License

License MIT license

computer-graphics-algorithms's People

Contributors

sajjad-ahmed avatar

Stargazers

 avatar Paripurna Dutta avatar

Watchers

James Cloos avatar  avatar  avatar

computer-graphics-algorithms's Issues

Writing 8 different functions for the 8 octants

We can make use of symmetric property to find the points in all 8 octants. We can write a single function (finding points in 1st octant) and transform those points to fit into the respective octants

void drawLine0(int x0, int y0, int x1, int y1, int zone)
    {
        x0=abs(x0);
        y0=abs(y0);
        x1=abs(x1);
        y1=abs(y1);
        if(zone==1||zone==2||zone==5||zone==6)
        {
            swap(x0,y0);
            swap(x1,y1);
        }
        float dx = x1 - x0, dy = y1 - y0;
        float dE = dy;
        float dNE = (dy - dx);
        float d = (dy) - dx/2;
        float x = x0, y = y0;

        glPointSize(2.0f);
        glBegin(GL_POINTS);
        glVertex2f(x, y);

        while (x <= x1)
        {
            if (d < 0)
            {
                //we increment x in every iteration
                x++;
                //dnew = dold + dE
                d = d + dE;

            } else
            {
                x++;
                y++;
                d = d + dNE;
            }
            if(zone==0)
            glVertex2f(x, y);
            else if(zone==1)
            glVertex2f(y,x);
            else if(zone==2)
            glVertex2f(-1*y,x);
            else if(zone==3)
            glVertex2f(-1*x,y);
            else if(zone==4)
            glVertex2f(-1*x,-1*y);
            else if(zone==5)
            glVertex2f(-1*y,-1*x);
            else if(zone==6)
            glVertex2f(y,-1*x);
            else if(zone==7)
            glVertex2f(x,-1*y);
           
        }
        glEnd();

    }

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.