This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>This is my test</title> | |
<style> | |
body | |
{ | |
background: #eeeeee; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// @param context the context of the canvas | |
/// @param color color of the grid in string format | |
/// @param size size of the quads or separation between them | |
/// @param tickness is the tickness of lines in the grid | |
function drawGrid(context, color, size, tickness) | |
{ | |
context.save(); | |
context.strokeStyle = color; | |
context.lineWidth = tickness; | |
for (var i = size; i < context.canvas.width; i += size) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// We assume that the location of GLSL program is stored in the variable <code>m_uIdProgram</code> as an unsigned int | |
// #include <iomanip> is necessary to use of setw (text formatting) | |
void CGLSLProgram::showDebugging() | |
{ | |
GLint iMaxLength, iNumAttrib, iNumUniform; | |
glGetProgramiv(m_uIdProgram, GL_ACTIVE_ATTRIBUTES, &iNumAttrib); | |
glGetProgramiv(m_uIdProgram, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &iMaxLength); | |
GLchar* name = new GLchar[iMaxLength]; | |
GLint written, size, location; | |
GLenum type; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function f_ab(x, y, pa, pb) | |
{ | |
return (pa.y - pb.y) * x + (pb.x - pa.x) * y + pa.x*pb.y - pb.x*pa.y; | |
} | |
/// @param context the context of the canvas | |
/// @param p1, p2, p3 The three points of the triangle | |
function drawTriangle(context, p1, p2, p3) | |
{ | |
var bbox = { top: {x: Math.min(p1.x, p2.x, p3.x), y:Math.min(p1.y, p2.y, p3.y)}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Algorithm of the middle point, where points are printing in console | |
/// Works independently of the position of both points. Also is more easy using Point from Drawing. | |
/// </summary> | |
/// <param name="x1">X value of the 1st point</param> | |
/// <param name="y1">Y value of the 1st point</param> | |
/// <param name="x2">X value of the 2nd point</param> | |
/// <param name="y2">Y value of the 2nd point</param> | |
static void Bresenham(int x1, int y1, int x2, int y2) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <functional> | |
int main() | |
{ | |
std::function<int(int)> fib = [&fib](int n) {return n < 2 ? 1 : fib(n-1) + fib(n-2);}; | |
std::cout << fib(9) << std::endl; | |
return EXIT_SUCCESS; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// iPair ==> Integer Pair | |
typedef std::pair<int, int> iPair; | |
std::vector<int> Graph::primtMST(int src) // Taking vertex 0 as source | |
{ | |
// Create a priority queue to store vertices that | |
// are being preinMST. This is weird syntax in C++. | |
// Refer below link for details of this syntax | |
// http://geeksquiz.com/implement-min-heap-using-stl/ | |
std::priority_queue< iPair, std::vector <iPair>, std::greater<iPair> > pq; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <chrono> | |
int main() | |
{ | |
std::cout << "Starting computation ..." << std::endl; | |
auto start = std::chrono::steady_clock::now(); | |
// insert code to measure here | |
auto end = std::chrono::steady_clock::now(); | |
auto diff = end - start; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Just for testing, a Loop subdivision algorithm to the input OBJ | |
// the output is the subdivide mesh | |
vtkSmartPointer<vtkPolyData> Subdivide(vtkSmartPointer<vtkPolyData> reader) | |
{ | |
// Subdivision filters only work on triangles | |
vtkSmartPointer<vtkTriangleFilter> triangles = vtkSmartPointer<vtkTriangleFilter>::New(); | |
triangles->SetInputData(reader); | |
triangles->Update(); | |
vtkSmartPointer<vtkPolyData> originalMesh = triangles->GetOutput(); // this is the original mesh actually |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include "GL/glut.h" | |
#include <iostream> | |
#pragma comment(lib, "glut32.lib") | |
#define WINDOW_TITLE "Project" | |
using namespace std; | |
const float ANGLE = 45.f; | |
const float FOV = 70.f; | |
const float NCP = 0.001f; |
OlderNewer