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
// Store an horizontal line (x1, y) --> (x2, y) | |
void line(int x1, int x2, int y) | |
{ | |
Color c; | |
c.r = lastColor.r; | |
c.g = lastColor.g; | |
c.b = lastColor.b; | |
for (int x = x1; x <= x2; x++) | |
{ | |
Vertex v; |
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
%output2.txt is the file to read | |
fid = fopen('output2.txt','rt'); | |
indata = textscan(fid, '%f %f %f', 'HeaderLines', 2); | |
fclose(fid); | |
cmp = jet(numel(indata{3})); %is the same using X or Y | |
scatter3(indata{1}, indata{2}, indata{3}, [], cmp); |
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
// Some types for easier vertex/color manipulation | |
struct Vertex | |
{ | |
GLfloat x; | |
GLfloat y; | |
}; | |
struct Color | |
{ | |
GLfloat r; |
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 <gl/GLU.h> | |
#include <iostream> | |
using namespace std; | |
GLUquadric* qobj; | |
GLUquadricObj *quadric; | |
void init(void) |
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
(DEFUN my-recursive-remove (x l) | |
(COND | |
((NULL l) NIL) | |
((NOT (ATOM (CAR l))) | |
(CONS (my-recursive-remove x (CAR l)) (my-recursive-remove x (CDR l))) | |
) | |
((AND (ATOM x) (EQ (CAR l) x)) (my-recursive-remove x (CDR l))) | |
(T (CONS (CAR l) (my-recursive-remove x (CDR l)))) | |
) | |
) |
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 <math.h> | |
using namespace std; | |
const int LENGTH = 100; | |
//const int LENGTH = 100; | |
//const int LENGTH = 10; | |
//int A [LENGTH] = { 3, 9, 10, 2, 18, 29, 1, 9, 11, 20 }; | |
int A[LENGTH] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; |
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
// http://www.spoj.com/problems/XMEN/ | |
#include <algorithm> | |
#include <cstdio> | |
#include <stack> | |
#include <iostream> | |
using namespace std; | |
#define MAX_N 100005 |
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
/// start, end are the ending point to write strLabel in the middle using VTK | |
auto fcnDrawLabel = [](vtkSmartPointer<vtkRenderWindow> renderWindow, glm::dvec3 start, glm::dvec3 end, std::string strLabel) -> vtkSmartPointer<vtkTextActor> { | |
vtkSmartPointer<vtkCoordinate> coordinate = vtkSmartPointer<vtkCoordinate>::New(); | |
coordinate->SetCoordinateSystemToWorld(); | |
coordinate->SetValue((start.x + end.x) / 2.0, (start.y + end.y) / 2.0, (start.z + end.z) / 2.0); | |
auto c = coordinate->GetComputedDisplayValue(renderWindow->GetRenderers()->GetFirstRenderer()); | |
vtkSmartPointer<vtkTextActor> textActor = vtkSmartPointer<vtkTextActor>::New(); | |
textActor->SetInput(strLabel.c_str()); |
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 <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <math.h> | |
class CMatrix4x4f | |
{ | |
public: // attributes |
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 <vtkImageImport.h> | |
// assume that dimensions contains the size of the volume (or image) | |
vtkNew<vtkImageImport> image_import; | |
image_import->SetDataSpacing(0.76, 0.76, 0.5); //x, y, z | |
image_import->SetDataOrigin(0, 0, 0); | |
image_import->SetWholeExtent(0, (int)dimensions[0] - 1, 0, (int)dimensions[1] - 1, 0, (int)dimensions[2] - 1); | |
image_import->SetDataExtentToWholeExtent(); | |
image_import->SetDataScalarTypeToFloat(); //float, or change to any datatype | |
image_import->SetNumberOfScalarComponents(1); |