Skip to content

Instantly share code, notes, and snippets.

View maxkarelov's full-sized avatar
🏠
Working from home

Max Karelov maxkarelov

🏠
Working from home
View GitHub Profile
@maxkarelov
maxkarelov / cohen-sutherland-algorithm.cp
Last active September 14, 2020 22:26
Code of Cohen-Sutherland Algoritm for Line Clipping in C++ Programming language
// Cohen–Sutherland Algorithm
bool clip(point &A, point &B, point Pmin, point Pmax) {
while (true) {
unsigned int C1 = 0;
if (A.x < Pmin.x) C1 += 1;
if (A.x > Pmax.x) C1 += 2;
if (A.y < Pmin.y) C1 += 4;
if (A.y > Pmax.y) C1 += 8;
unsigned int C2 = 0;
@maxkarelov
maxkarelov / nicol-lee-nicol-algorithm.cpp
Created March 24, 2015 16:25
Code of Nicol Lee Nicol Algorithm for Line Clipping in C++ Programming language
bool clip(point &A, point &B, point Pmin, point Pmax) {
/* 1 */
if (A.x > B.x) std::swap(A, B);
/* 2 */
int C1 = 0;
if (A.x < Pmin.x) C1 += 1;
if (A.x > Pmax.x) C1 += 2;
if (A.y < Pmin.y) C1 += 4;
if (A.y > Pmax.y) C1 += 8;
@maxkarelov
maxkarelov / liang-barsky-algorithm.cpp
Created April 14, 2015 09:27
Implementation of the Liang–Barsky algorithm for clipping polygons
#define INFINITY float::MaxValue
polygon^ Pclip (polygon^ P, point Pmin, point Pmax) {
polygon^ P1 = gcnew polygon(0);
point A = P[P->Count - 1];
int k = 0;
while (k < P->Count) {
point B = P[k];
float t1out, t2in, t2out,
xin, xout, txin, txout,
@maxkarelov
maxkarelov / fc-algorithm.cpp
Created April 20, 2015 15:19
Code of FC-Algorithm for Line Clipping in C++ Programming language
void Clip1Left(point &A, point &B, point Pmin, point Pmax)
{
A.y = B.y - (B.x - Pmin.x) * (B.y - A.y) / (B.x - A.x);
A.x = Pmin.x;
}
void Clip1Top(point &A, point &B, point Pmin, point Pmax)
{
A.x = B.x - (B.y - Pmax.y) * (B.x - A.x) / (B.y - A.y);
A.y = Pmax.y;
@maxkarelov
maxkarelov / mallot-polygons-clipping-algorithm.cpp
Last active August 29, 2015 14:20
The implementation of the Mallot algorithm of polygon clipping
int ExtCode(point A, point Pmin, point Pmax) {
int C = 0;
if (A.x < Pmin.x) {
C += 1;
if (A.y < Pmin.y) C += 20;
if (A.y > Pmax.y) C += 24;
return C;
}
if (A.x > Pmax.x) {
FROM debian:wheezy
RUN sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && \
apt-get update && \
apt-get install -y nasm gcc-multilib && \
rm -rf /var/lib/apt/lists/*
#pragma once
#include "stdafx.h"
#include "Transform.h"
#include <math.h>
std::vector<mat> matrices(0);
mat L;
mat3D T;
#pragma once
#define HEIGHT this->ClientRectangle.Height
#define WIDTH this->ClientRectangle.Width
namespace test3v11 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
@maxkarelov
maxkarelov / getInnerPoint.cpp
Last active August 29, 2015 14:21
Function for getting the inner point of polygon
point getInnerPoint(polygon^ P) {
// the following variables have a strict order: y_s < y_ss
float y_s = float::MaxValue,
y_ss = float::MaxValue;
// find two different min values
for (int i = 0; i < P->Count; i++) {
if (P[i].y < y_s) {
y_ss = y_s;
y_s = P[i].y;
Failed StepArgumentException with 'requirement failed: No keystore provided'
########################### MANIFEST ################################
version: "1.1"
header: {}
launch:
steps:
provisionMicroUbuntuAmazon:
action: provisionVms