Giter Site home page Giter Site logo

amagnum / liang-barsky-line-clipping-algorithm-cpp Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 2.43 MB

Liang Barsky line clipping algorithm cpp code with all intermediate steps

C++ 81.56% CMake 2.88% C 2.26% Shell 0.17% Cuda 1.16% Fortran 11.77% Python 0.08% JavaScript 0.07% CSS 0.05%
liang-barsky line-clipping computer-graphics

liang-barsky-line-clipping-algorithm-cpp's Introduction

Liang-Barsky-line-clipping-algorithm-cpp

Liang Barsky line clipping algorithm cpp code with all intermediate steps

Run

g++ liang_barsky.cpp > eliang
./eliang < liang.in

Input format

Xmin Xmax Ymin Ymax
P1x P1y
P2x P2y

Output

p1 = -Δx = -50      q1 = x1 - x_min = -20
p2 = Δx  = 50      q2 = x_max - x1 = 70
p3 = -Δy = -70      q3 = y1 - y_min = -10
p4 = Δy  = 70      q4 = y_max - y1 = 60

for Left : 
	Potential Entering
	t = -20/-50 = 0.4
for Right : 
	Potential Leaving
	t = 70/50 = 1.4
for Bottom : 
	Potential Entering
	t = -10/-70 = 0.142857
for Top : 
	Potential Leaving
	t = 60/70 = 0.857143

t_min = max(0, all_t_PE) = 0.4
t_max = min(1, all_t_PL) = 0.857143

point corresponding to t_min :

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.