Commits

Anonymous committed db0678e

Adding my files.

Comments (0)

Files changed (8)

curve/BesierAssignment.cpp

+/*****************************************************************************
+ Program file name: main.cpp	       OS: Windows 7	    Assignment #09
+ Programmer: Nicholas Streifling       Class: Computer Graphics   Date: 2-16-11
+ Compiler: GNU C++ Compiler
+ 
+ Assistance/references: None
+ Description:  Plots a Bezier curve
+ Inputs: KB: control points and when to end program
+ Outputs: Monitor: Points, lines connecting points, and curve going between points
+ 
+ Special Comments: 
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~Grading Criteria~~~~~~~~~~~~~~~~~~~~~~~~~~
+ Assignment Requirements: ___/3.0
+ Code Format/Cosmetics: ___/3.0
+ Header & Code Comments: ___/2.0
+ Output Format/Cosmetics: ___/2.0
+ 
+ ***Does Not Compile***: ___ (-10.0)
+ ***Late Work Deduction***: ___ (-0.5/day)
+ Total Grade: ___/10.0
+
+*****************************************************************************/
+
+#include <iostream>
+#include <conio.h>
+#include <cstdlib>
+#include <graphics.h>
+#include <cmath>
+#include <fstream>
+#include <time.h>
+
+using namespace std;
+
+const int xRes = 640;
+const int yRes = 480;
+const int nmax = 20;
+const int mmax = 500;
+int ctrlpoint[nmax][2];
+float c[nmax];
+float x[mmax], y[mmax];
+
+int round(float f);
+void get_ctrl_points(int n);
+void coefs(int n);
+float factorial(float num);
+float blending_value(int n, int i, float u);
+void curve_points(int n, float u, float &x, float &y);
+void plot_ctrlpoints(int n);
+
+int main()
+{
+    bool flag0;
+	int n = rand() % 15, m = 270;
+
+	srand(34563);
+
+	for(int j = 0; j <= n; j++)
+    {
+        ctrlpoint[j][0] = rand() % xRes;
+        ctrlpoint[j][1] = rand() % yRes;
+    }
+
+    flag0 = true;
+    while(flag0)
+    {
+        cout << "Enter n for n+1 control points for the Bezier curve: ";
+        cin >> n;
+        if(cin.fail())
+            cout << "General input error!" << endl;
+        else if(n < 1)
+            cout << "n is too low!" << endl;
+        else if(n > nmax - 1)
+            cout << "n is too high!" << endl;
+        else
+            flag0 = false;
+    }
+	get_ctrl_points(n);
+	coefs(n);
+	flag0 = true;
+	while(flag0)
+	{
+        cout << "Enter the no. of st. line segments to approximate the Bezier curve: ";
+        cin >> m;
+        if(cin.fail())
+            cout << "General input error!" << endl;
+        else if(m < n + 1)
+            cout << "m is too low!" << endl;
+        else if(n > mmax - 1)
+            cout << "m is too high!" << endl;
+        else
+            flag0 = false;
+	}
+
+	for(int j = 0; j <= m; j++)
+	{
+		curve_points(n, static_cast<float>(j) / static_cast<float>(m), x[j], y[j]);
+	}
+
+	ofstream write;
+	write.open("debug.txt");
+	for(int j = 0; j <= n; j++)
+	{
+		write << c[n] << endl;
+	}
+	write << endl;
+	for(int j = 0; j <= n; j++)
+		write << x[j] << ' ' << y[j] << endl;
+    write.close();
+
+	initwindow(xRes, yRes);
+	plot_ctrlpoints(n);
+	for(int j = 0; j < n; j++)
+        line(ctrlpoint[j][0], ctrlpoint[j][1], ctrlpoint[j + 1][0], ctrlpoint[j + 1][1]);
+    setcolor(YELLOW);
+	for(int j = 0; j < m - 1; j++)
+	{
+		line(round(x[j]), round(y[j]), round(x[j + 1]), round(y[j + 1]));
+	}
+	getch();
+	closegraph();
+	return 0;
+}
+
+int round(float f)
+{
+	return static_cast<int>(f + 0.5);
+}
+
+void get_ctrl_points(int n)
+{
+	for(int j = 0; j <= n; j++)
+	{
+		cout << "For P" << j << " x = ";
+		cin >> ctrlpoint[j][0];
+		cout << "       y = ";
+		cin >> ctrlpoint[j][1];
+	}
+	return;
+}
+
+void coefs(int n)
+{
+	float fn = factorial(static_cast<float>(n));
+
+	for(int j = 0; j <= n; j++)
+	{
+		c[j] = fn / (factorial(static_cast<float>(j)) * factorial(static_cast<float>(n) - static_cast<float>(j)));
+	}
+	return;
+}
+
+float factorial(float num)
+{
+    float out = 1;
+    while(num > 1)
+    {
+        out *= num;
+        num--;
+    }
+    return out;
+}
+
+float blending_value(int n, int i, float u)
+{
+	return c[i] * pow(u, i) * pow(1 - u, n - i);
+}
+
+void curve_points(int n, float u, float &x, float &y)
+{
+	float bv;
+	x = y = 0;
+
+	for(int j = 0; j <= n; j++)
+	{
+		bv = blending_value(n, j, u);
+		x = x + bv * ctrlpoint[j][0];
+		y = y + bv * ctrlpoint[j][1];
+	}
+	return;
+}
+
+void plot_ctrlpoints(int n)
+{
+	char str[10];
+
+	for(int k = 0; k <= n; k++)
+	{
+		itoa(k, str, 10);
+		outtextxy(ctrlpoint[k][0] + 4, ctrlpoint[k][1] + 4, str);
+		circle(ctrlpoint[k][0], ctrlpoint[k][1], 1);
+		circle(ctrlpoint[k][0], ctrlpoint[k][1], 3);
+
+	}
+	return;
+}
Binary file added.
+#include "stdafx.h"
+#include "include/draw.h"
+#include "include/bezier.h"
+#include "SDL_gfxPrimitives.h"
+
+//Constructor, sets xy via array
+Bezier::Bezier(Point coord[4])
+{
+  for(int i=0; i < 4; i++)
+  {
+    points[i].x = coord[i].x;
+    points[i].y = coord[i].y;
+  }
+}
+
+// constructor for bezier at a point to the mouse which will be changing
+Bezier::Bezier(Point start)
+{
+  for (int i = 0; i < 4; i++)
+  {
+    points[i].x = start.x;
+    points[i].y = start.y;
+  }
+}
+//constructor, if no beginning coordinates are set.
+Bezier::Bezier()
+{
+  for (int i = 0; i < 4; i++)
+  {
+    points[i].x = 0;
+    points[i].y = 0;
+  }
+
+}
+
+//constructor, if beginning coordinates are set.
+Bezier::Bezier(int a, int b, int a1, int b1, int a2, int b2, int a3, int b3)
+{
+  points[0].x = a;
+  points[0].y = b;
+  points[1].x = a1;
+  points[1].y = b1;
+  points[2].x = a2;
+  points[2].y = b2;
+  points[3].x = a3;
+  points[3].y = b3;
+}
+
+//Constructor, takes points to create curve
+Bezier::Bezier(int from, int to, Game * g)
+{
+  int x1;
+  int x2;
+  int y1;
+  int y2;
+  x1 = points[0].x = g->nodes[from]->node.x;
+  y1 = points[0].y = g->nodes[from]->node.y;
+  x2 = points[3].x = g->nodes[to]->node.x;
+  y2 = points[3].y = g->nodes[to]->node.y;
+  // Calculate control points to make curves
+  int rise = (y1-y2);   // the rise of the line between the nodes
+  int run = (x1-x2);    // The run of the line between the nodes
+
+  if (abs(rise) > abs(run)) // is the y value farther then the x values
+  {
+    points[1].x = x1 - run/2;
+    points[1].y = y1;
+    points[2].x = x2 + run/2;
+    points[2].y = y2;
+  }
+  else
+  {
+    points[1].x = x1;
+    points[1].y = y1 - rise/2;
+    points[2].x = x2;
+    points[2].y = y2 + rise/2;
+  }
+}
+
+//Constructor, copies values from old curve
+Bezier::Bezier(Bezier * oldCurve)
+{
+  // Copy the values into this curve from the old curve
+  for (int i = 0; i < 4; i++)
+  {
+    points[i].x = oldCurve->points[i].x;
+    points[i].y = oldCurve->points[i].y;
+  }
+}
+
+//gets the coordinates of the selected point
+Point Bezier::getcoord(int point)
+{
+  Point temp = {0,0};
+
+  if (point < 1 || point > 4)
+    return temp;
+
+  return points[point-1];
+}
+
+//returns all of the coordinates
+Point * Bezier::getcoord(void)
+{
+  return points;
+}
+
+//sets the coordinates of the selected point to the sent coordinates
+bool Bezier::setcoord(int point,Point coord)
+{
+  if (point < 1 || point > 4)
+    return 0;
+
+  points[point-1].x = coord.x;
+  points[point-1].y = coord.y;
+
+  return 1;
+}
+
+//sets the coordinates of the selected point to sent x and y
+bool Bezier::setcoord(int point,int x, int y)
+{
+  if (point < 1 || point > 4)
+    return 0;
+
+  points[point-1].x = x;
+  points[point-1].y = y;
+
+  return 1;
+}
+
+//sets the coordinates of the selected point via array
+bool Bezier::setcoord(Point coord[4])
+{
+  for (int i=0; i < 4; i++)
+  {
+    points[i].x = coord[i].x;
+    points[i].y = coord[i].y;
+  }
+
+  return 1;
+}
+
+void Bezier::setCurve(int x, int y) // Set the curve up with the new x,y for the second point
+{
+  // First thing lets set the second end point
+  points[3].x = x;
+  points[3].y = y;
+
+  // Lets just create a straight line for now
+  points[2].x = x;
+  points[2].y = y;
+}
+//sets the coordinates of the selected point to sent x and y
+bool Bezier::adjustCoord(int point,int x, int y)
+{
+  switch (point)
+  {
+  case CURVE_START:
+    points[0].x = x;
+    points[0].y = y;
+    // set the 1st control point to match
+    break;
+  case CURVE_END:
+    points[3].x = x;
+    points[3].y = y;
+    //set the 2nd control point to match
+    break;
+  }
+
+  int x1 = points[0].x;
+  int y1 = points[0].y;
+  int x2 = points[3].x;
+  int y2 = points[3].y;
+
+  // Calculate control points to make curves
+  int rise = (y1-y2);   // the rise of the line between the nodes
+  int run = (x1-x2);    // The run of the line between the nodes
+
+  if (abs(rise) > abs(run)) // is the y value farther then the x values
+  {
+    points[1].x = x1 - run/2;
+    points[1].y = y1;
+    points[2].x = x2 + run/2;
+    points[2].y = y2;
+  }
+  else
+  {
+    points[1].x = x1;
+    points[1].y = y1 - rise/2;
+    points[2].x = x2;
+    points[2].y = y2 + rise/2;
+  }
+  return 1;
+}
+
+
+//draw actual curve
+void Bezier::draw(SDL_Surface * mysurface)
+{
+  Sint16 vx[4];
+  Sint16 vy[4];
+
+  Uint8 r = 0;
+  Uint8 g = 255;
+  Uint8 b = 0;
+
+  // Center line
+  for (int i=0; i < 4; i++)
+  {
+    vx[i] = points[i].x;
+    vy[i] = points[i].y;
+  }
+  //bezierRGBA (surfacetype, x-vertex, y-vertex, #ofvetecies, #ofsteps, red,blue,green,alpha)
+  bezierRGBA (mysurface, vx, vy, 4, 100, r,g,b,255);
+
+  // Up line
+  for (int i=0; i < 4; i++)
+  {
+    vx[i] = points[i].x;
+    vy[i] = points[i].y-1;
+  }
+  //bezierRGBA (surfacetype, x-vertex, y-vertex, #ofvetecies, #ofsteps, red,blue,green,alpha)
+  bezierRGBA (mysurface, vx, vy, 4, 100, r,g,b,127);
+
+  // Left line
+  for (int i=0; i < 4; i++)
+  {
+    vx[i] = points[i].x-1;
+    vy[i] = points[i].y;
+  }
+  //bezierRGBA (surfacetype, x-vertex, y-vertex, #ofvetecies, #ofsteps, red,blue,green,alpha)
+  bezierRGBA (mysurface, vx, vy, 4, 100, r,g,b,127);
+
+  // bottom line
+  for (int i=0; i < 4; i++)
+  {
+    vx[i] = points[i].x;
+    vy[i] = points[i].y+1;
+  }
+  //bezierRGBA (surfacetype, x-vertex, y-vertex, #ofvetecies, #ofsteps, red,blue,green,alpha)
+  bezierRGBA (mysurface, vx, vy, 4, 100,  r,g,b,127);
+
+  // Right line
+  for (int i=0; i < 4; i++)
+  {
+    vx[i] = points[i].x+1;
+    vy[i] = points[i].y;
+  }
+    //bezierRGBA (surfacetype, x-vertex, y-vertex, #ofvetecies, #ofsteps, red,blue,green,alpha)
+    bezierRGBA (mysurface, vx, vy, 4, 100,  r,g,b,127);
+}
+
+// destructor
+Bezier::~Bezier()
+{
+  // Free the memory
+  // Shouldnt be anything additional
+}
+#pragma once
+
+#include "draw.h"
+#include "game.h"
+#include "SDL_gfxPrimitives.h"
+//header for drawing the curves
+
+enum Curve{CURVE_START,
+      CURVE_END};
+
+//class declaratio
+class Bezier{
+	private:
+		Point points[4];
+	public:
+		Bezier(int,int,int,int,int,int,int,int);//constructor, if beginning coordinates are set.
+		Bezier(Point coord[4]);//constructor
+    Bezier(Point start);
+    Bezier(Bezier *);
+		Bezier(void);//constructor, if no beginning coordinates are set.
+		Bezier(Point,Point,Point,Point);
+    Bezier(int from, int to, Game * game);
+		Point getcoord(int point);//gets the coordinates of the selected point
+		Point * getcoord(void);//returns all coordinates
+    void setCurve(int x, int y);    // Sets the curve up with the second end point at (x,y)
+		bool setcoord(int point, Point coord);//sets the coordinates of the selected point to the sent coordinates
+		bool setcoord(int point, int x, int y);//sets the coordinates of the selected point to sent x and y
+		bool setcoord(Point coords[4]);//sets the coordinates of the selected point by array
+		bool adjustCoord(int point, int x, int y);//sets the coordinates of the selected point to sent x and y
+    void draw(SDL_Surface *);//draws the curve
+    ~Bezier();
+};
+
+

curve/cylinderAssignment.cpp

+/*****************************************************************************
+ Program file name:cg13.cpp          OS:Ubuntu 10.04  Assignment #13
+ Programmer: Nicholas Streifling     Class: Computer Graphics    Date:3-7-11
+ Compiler:GNU Compiler Collection
+ 
+ Assistance/references:Chris
+ Description:Draws a cylinder with an apperant light source.
+ Inputs:up, down, left, right, a, d to rotate
+ Outputs:Picture of a cylinder
+ 
+ Special Comments: 
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~Grading Criteria~~~~~~~~~~~~~~~~~~~~~~~~~~
+ Assignment Requirements: ___/3.0
+ Code Format/Cosmetics: ___/3.0
+ Header & Code Comments: ___/2.0
+ Output Format/Cosmetics: ___/2.0
+ 
+ ***Does Not Compile***: ___ (-10.0)
+ ***Late Work Deduction***: ___ (-0.5/day)
+ Total Grade: ___/10.0
+
+*****************************************************************************/
+
+#include <cstdlib>
+#include <GL/gl.h>
+#include <GL/glu.h>
+#include <SDL/SDL.h>
+#include <iostream>
+
+using namespace std;
+
+const int xSize = 500;
+const int ySize = 500;
+const int zSize = 50;
+
+void drawMe();
+
+int main()
+{
+	SDL_Event event;
+
+	if(SDL_Init(SDL_INIT_VIDEO) < 0)
+	{
+		fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
+		exit(1);
+	}
+	atexit(SDL_Quit);
+
+	SDL_Surface *screen;
+
+	screen = SDL_SetVideoMode(xSize, ySize, 24, SDL_OPENGL);
+	if(screen == NULL)
+	{
+		fprintf(stderr, "Unable to set xSize X ySize video: %s\n", SDL_GetError());
+		SDL_Quit();
+		exit(1);
+	}
+
+	glMatrixMode(GL_PROJECTION);
+	glLoadIdentity();
+	glOrtho(-30, 30, -30, 30, -30, 30);
+	glMatrixMode(GL_MODELVIEW);
+	glEnable(GL_DEPTH_TEST);
+
+	glLoadIdentity();
+	drawMe();//x, y, z);
+
+	while(true)
+	{
+		while(SDL_PollEvent(&event))
+		{
+			switch(event.type)
+			{
+			case SDL_KEYDOWN:
+				switch(event.key.keysym.sym)
+				{
+				case SDLK_ESCAPE://if esc, then quit
+					exit(0);
+				case SDLK_a://rotate left about z-axis
+					glRotatef(22.5, 0, 0, 1);
+					drawMe();
+					break;
+				case SDLK_d://rotate right about z-axis
+					glRotatef(-22.5, 0, 0, 1);
+					drawMe();
+					break;
+				case SDLK_RIGHT://rotate left about y-axis
+					glRotatef(22.5, 0, 1, 0);
+					drawMe();
+					break;
+				case SDLK_LEFT://rotate right about y-axis
+					glRotatef(-22.5, 0, 1, 0);
+					drawMe();
+					break;
+				case SDLK_UP://rotate left about x-axis
+					glRotatef(22.5, 1, 0, 0);
+					drawMe();
+					break;
+				case SDLK_DOWN://rotate right about x-axis
+					glRotatef(-22.5, 1, 0, 0);
+					drawMe();
+				}
+				break;
+			case SDL_QUIT://X button on the window
+				exit(0);
+			}
+		}
+	}
+}
+
+void drawMe()
+{
+	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+	//rectangles for the sides.
+	glColor3ub(179, 38, 0);
+	glBegin(GL_QUADS);
+	glVertex3f(0.0, 20.0, 5.0);
+	glVertex3f(0.0, -20.0, 5.0);
+	glColor3ub(239, 51, 0);
+	glVertex3f(1.9134, -20.0, 4.6194);
+	glVertex3f(1.9134, 20.0, 4.6194);
+	glEnd();
+
+	glColor3ub(239, 51, 0);
+	glBegin(GL_QUADS);
+	glVertex3f(1.9134, 20.0, 4.6194);
+	glVertex3f(1.9134, -20.0, 4.6194);
+	glColor3ub(179, 38, 0);
+	glVertex3f(3.5355, -20.0, 3.5355);
+	glVertex3f(3.5355, 20.0, 3.5355);
+	glEnd();
+
+	glColor3ub(179, 38, 0);
+	glBegin(GL_QUADS);
+	glVertex3f(3.5355, 20.0, 3.5355);
+	glVertex3f(3.5355, -20.0, 3.5355);
+	glColor3ub(120, 26, 0);
+	glVertex3f(4.6194, -20.0, 1.9134);
+	glVertex3f(4.6194, 20.0, 1.9134);
+	glEnd();
+
+	glColor3ub(120, 26, 0);
+	glBegin(GL_QUADS);
+	glVertex3f(4.6194, 20.0, 1.9134);
+	glVertex3f(4.6194, -20.0, 1.9134);
+	glColor3ub(60, 13, 0);
+	glVertex3f(5.0, -20.0, 0.0);
+	glVertex3f(5.0, 20.0, 0.0);
+	glEnd();
+
+	glColor3ub(60, 13, 0);
+	glBegin(GL_QUADS);
+	glVertex3f(5.0, 20.0, 0.0);
+	glVertex3f(5.0, -20.0, 0.0);
+	glVertex3f(4.6194, -20.0, -1.9134);
+	glVertex3f(4.6194, 20.0, -1.9134);
+	glEnd();
+
+	glColor3ub(60, 13, 0);
+	glBegin(GL_QUADS);
+	glVertex3f(4.6194, 20.0, -1.9134);
+	glVertex3f(4.6194, -20.0, -1.9134);
+	glVertex3f(3.5355, -20.0, -3.5355);
+	glVertex3f(3.5355, 20.0, -3.5355);
+	glEnd();
+
+	glColor3ub(60, 13, 0);
+	glBegin(GL_QUADS);
+	glVertex3f(3.5355, 20.0, -3.5355);
+	glVertex3f(3.5355, -20.0, -3.5355);
+	glVertex3f(1.9134, -20.0, -4.6194);
+	glVertex3f(1.9134, 20.0, -4.6194);
+	glEnd();
+
+	glColor3ub(60, 13, 0);
+	glBegin(GL_QUADS);
+	glVertex3f(1.9134, 20.0, -4.6194);
+	glVertex3f(1.9134, -20.0, -4.6194);
+	glVertex3f(0.0, -20.0, -5.0);
+	glVertex3f(0.0, 20.0, -5.0);
+	glEnd();
+
+	glColor3ub(60, 13, 0);
+	glBegin(GL_QUADS);
+	glVertex3f(0.0, 20.0, -5.0);
+	glVertex3f(0.0, -20.0, -5.0);
+	glVertex3f(-1.9134, -20.0, -4.6194);
+	glVertex3f(-1.9134, 20.0, -4.6194);
+	glEnd();
+
+	glColor3ub(60, 13, 0);
+	glBegin(GL_QUADS);
+	glVertex3f(-1.9134, 20.0, -4.6194);
+	glVertex3f(-1.9134, -20.0, -4.6194);
+	glVertex3f(-3.5355, -20.0, -3.5355);
+	glVertex3f(-3.5355, 20.0, -3.5355);
+	glEnd();
+
+	glColor3ub(60, 13, 0);
+	glBegin(GL_QUADS);
+	glVertex3f(-3.5355, 20.0, -3.5355);
+	glVertex3f(-3.5355, -20.0, -3.5355);
+	glVertex3f(-4.6194, -20.0, -1.9134);
+	glVertex3f(-4.6194, 20.0, -1.9134);
+	glEnd();
+
+	glColor3ub(60, 13, 0);
+	glBegin(GL_QUADS);
+	glVertex3f(-4.6194, 20.0, -1.9134);
+	glVertex3f(-4.6194, -20.0, -1.9134);
+	glVertex3f(-5.0, -20.0, 0.0);
+	glVertex3f(-5.0, 20.0, 0.0);
+	glEnd();
+
+	glColor3ub(60, 13, 0);
+	glBegin(GL_QUADS);
+	glVertex3f(-5.0, 20.0, 0.0);
+	glVertex3f(-5.0, -20.0, 0.0);
+	glVertex3f(-4.6194, -20.0, 1.9134);
+	glVertex3f(-4.6194, 20.0, 1.9134);
+	glEnd();
+
+	glColor3ub(60, 13, 0);
+	glBegin(GL_QUADS);
+	glVertex3f(-4.6194, 20.0, 1.9134);
+	glVertex3f(-4.6194, -20.0, 1.9134);
+	glVertex3f(-3.5355, -20.0, 3.5355);
+	glVertex3f(-3.5355, 20.0, 3.5355);
+	glEnd();
+
+	glColor3ub(60, 13, 0);
+	glBegin(GL_QUADS);
+	glVertex3f(-3.5355, 20.0, 3.5355);
+	glVertex3f(-3.5355, -20.0, 3.5355);
+	glColor3ub(120, 26, 0);
+	glVertex3f(-1.9134, -20.0, 4.6194);
+	glVertex3f(-1.9134, 20.0, 4.6194);
+	glEnd();
+
+	glColor3ub(120, 26, 0);
+	glBegin(GL_QUADS);
+	glVertex3f(-1.9134, 20.0, 4.6194);
+	glVertex3f(-1.9134, -20.0, 4.6194);
+	glColor3ub(179, 38, 0);
+	glVertex3f(0.0, -20.0, 5.0);
+	glVertex3f(0.0, 20.0, 5.0);
+	glEnd();
+
+	//bottom polygon (in shadow)
+	glColor3ub(60, 13, 0);
+	glBegin(GL_POLYGON);
+	glVertex3f(4.6194, -20.0, -1.9134);
+	glVertex3f(3.5355, -20.0, -3.5355);
+	glVertex3f(1.9134, -20.0, -4.6194);
+	glVertex3f(0.0, -20.0, -5.0);
+	glVertex3f(-1.9134, -20.0, -4.6194);
+	glVertex3f(-3.5355, -20.0, -3.5355);
+	glVertex3f(-4.6194, -20.0, -1.9134);
+	glVertex3f(-5.0, -20.0, 0.0);
+	glVertex3f(-4.6194, -20.0, 1.9134);
+	glVertex3f(-3.5355, -20.0, 3.5355);
+	glVertex3f(-1.9134, -20.0, 4.6194);
+	glVertex3f(0.0, -20.0, 5.0);
+	glVertex3f(1.9134, -20.0, 4.6194);
+	glVertex3f(3.5355, -20.0, 3.5355);
+	glVertex3f(4.6194, -20.0, 1.9134);
+	glVertex3f(5.0, -20.0, 0.0);
+	glEnd();
+
+	//top polygon (with texture)
+	glColor3ub(203, 48, 0);
+	glBegin(GL_POLYGON);
+	glVertex3f(5.0, 20.0, 0.0);
+	glColor3ub(191, 47, 0);
+	glVertex3f(4.6194, 20.0, -1.9134);
+	glColor3ub(189, 46, 0);
+	glVertex3f(3.5355, 20.0, -3.5355);
+	glColor3ub(177, 45, 0);
+	glVertex3f(1.9134, 20.0, -4.6194);
+	glColor3ub(165, 44, 0);
+	glVertex3f(0.0, 20.0, -5.0);
+	glColor3ub(153, 43, 0);
+	glVertex3f(-1.9134, 20.0, -4.6194);
+	glColor3ub(165, 44, 0);
+	glVertex3f(-3.5355, 20.0, -3.5355);
+	glColor3ub(177, 45, 0);
+	glVertex3f(-4.6194, 20.0, -1.9134);
+	glColor3ub(189, 46, 0);
+	glVertex3f(-5.0, 20.0, 0.0);
+	glColor3ub(191, 47, 0);
+	glVertex3f(-4.6194, 20.0, 1.9134);
+	glColor3ub(203, 48, 0);
+	glVertex3f(-3.5355, 20.0, 3.5355);
+	glColor3ub(215, 49, 0);
+	glVertex3f(-1.9134, 20.0, 4.6194);
+	glColor3ub(227, 50, 0);
+	glVertex3f(0.0, 20.0, 5.0);
+	glColor3ub(239, 51, 0);
+	glVertex3f(1.9134, 20.0, 4.6194);
+	glColor3ub(227, 50, 0);
+	glVertex3f(3.5355, 20.0, 3.5355);
+	glColor3ub(215, 49, 0);
+	glVertex3f(4.6194, 20.0, 1.9134);
+	glEnd();
+	
+
+	SDL_GL_SwapBuffers();
+	return;
+}
+cd Documents/Sprouts/Ours/
+put proto.cpp
+exit
+//In case of confusion: the command to compile is:
+//g++ proto.cpp -lGL -lSDL
+
+#include <GL/gl.h>
+#include <GL/glu.h>
+#include <SDL/SDL.h>
+#include <unistd.h>
+#include <cmath>
+#include <iostream>
+
+using namespace std;
+
+struct Point
+{//structure for points in the plane
+	float x;
+	float y;
+
+	Point() : x(0.0), y(0.0) {}//default constructor
+	Point(float sx, float sy) : x(sx), y(sy) {}//explicit constructor
+
+	Point& operator=(const Point& source)
+	{
+		x = source.x;
+		y = source.y;
+		return *this;
+	}
+}a(-0.67, 0.33),
+b(0.0, 0.0),
+c(0.67, -0.33),
+d(0.0, 0.33),
+e(0.67, 0.0),
+f(0.67, 0.33);//example points
+
+struct Line
+{//structure to hold variables for a line in standard form (Ax+By+C=0)
+	float A;
+	float B;
+	float C;
+	Point mid;//midpoint used in the calculation to find a perpendicular line
+
+	Line() : A(0.0), B(0.0), C(0.0) {}//default constructor
+	Line(Point p0, Point p1) : A(-(p0.y - p1.y)), B(p0.x - p1.x)
+	{//explicit constructor
+		mid.x = (p0.x + p1.x) / 2.0;
+		mid.y = (p0.y + p1.y) / 2.0;
+
+		C = ((p0.y - p1.y) * p0.x) - ((p0.x - p1.x) * p0.y);
+	}
+
+	Line perp()
+	{//returns a perpendicular line passing through the midpoint
+		Line out;
+		out.A = -B;
+		out.B = A;
+		out.C = (-A * mid.y) + (B * mid.x);
+		return out;
+	}
+	/*void draw()
+	{//debugging function that draws non-vertical lines
+		if(B)
+		{
+			glBegin(GL_LINES);
+			glColor3ub(231, 64, 0);
+			glVertex2f(-2.0, (A * 2.0 - C) / B);
+			glColor3ub(0, 178, 0);
+			glVertex2f(2.0, (-A * 2.0 - C) / B);
+			glEnd();
+		}
+		else
+		{
+		}
+		return;
+	}*/
+
+	Line &operator=(const Line& s)
+	{
+		A = s.A;
+		B = s.B;
+		C = s.C;
+		mid = s.mid;
+		return *this;
+	}
+};
+
+struct pList
+{//node for the linked list of the path that the bezier curve is to follow
+	Point stone;//"stepping stone" on the path
+	pList* link;//link to next step
+
+	//constructor that takes a single point and a link, for use with endpoints
+	pList(Point end, pList *sLink) : stone(end), link(sLink) {}
+	//constructor that takes two points and stores their midpoint, for use with
+	//steps that run between close points that must not be crossed
+	pList(Point h, Point l, pList *sLink)
+	{
+		stone.x = (h.x + l.x) / 2.0;
+		stone.y = (h.y + l.y) / 2.0;
+		link = sLink;
+	}
+}y(a, NULL), u(d, Point(0.0, 1.0), &y), i(d, f, &u), o(b, e, &i), p(c, &o),
+r(c, NULL), t(Point(0.33, 0.165), &r), w(a, &t);//2 example paths
+//The way that I designed these to be built was to start with the end point and 
+//a link to NULL, then the next two points to go between with a link to the 
+//node containing the endpoint, and so forth until a node with the beginning
+//point is added in a similar manner to a stack, and then only the node with
+//the beginning point needs to be kept track of.
+
+void plot(Point p)
+{//function that plots example points as aurora triangles; for use in the 
+//example code, not in the final project
+	glBegin(GL_TRIANGLES);
+	glColor3ub(255, 0, 0);
+	glVertex2f(p.x, p.y + 0.05);
+	glColor3ub(0, 255, 0);
+	glVertex2f(p.x - 0.05, p.y - 0.05);
+	glColor3ub(0, 0, 255);
+	glVertex2f(p.x + 0.05, p.y - 0.05);
+	glEnd();
+}
+
+inline float dist(Point p0, Point p1)
+{//distance between two points
+	return sqrt(pow(p0.x - p1.x, 2) + pow(p0.y - p1.y, 2));
+}
+
+Line qbCurve(Point end0, Point ctrl, Point end1, unsigned short res)
+{//quadratic Bezier curve function: takes two end points, a control point, and the
+//number of line segmets that should be used to construct the curve.
+//returns the last line in the curve
+	double inc = 1.0 / static_cast<double>(res);//convert the number of lines
+						//to an incrument value
+	Point p0;
+	Point p1 = end0;
+
+	for(double t = 0.0; t <= 1.0; t += inc)
+	{//loop for the perametric quadratic bezier curve function that runs [0, 1] in <res> steps
+		p0 = p1;//set p0 as the new beginning point
+		//parametric quadratic bezier curve function:
+		p1.x = ((1 - t) * (1 - t) * end0.x) + (2 * (1 - t) * t * ctrl.x) + (t * t * end1.x);
+		p1.y = ((1 - t) * (1 - t) * end0.y) + (2 * (1 - t) * t * ctrl.y) + (t * t * end1.y);
+		glBegin(GL_LINES);//Plot the line segment
+		glVertex2f(p0.x, p0.y);
+		glVertex2f(p1.x, p1.y);
+		glEnd();
+	}
+
+	return Line(p0, p1);//return the last line segment calculated
+}
+
+Point intersect(Point start, Line l0, Line l1)
+{//Function taking a starting point and two lines with which to find their intersection point
+	if((l0.A == l1.A) && (l0.B == l1.B) && (l0.C == l1.C))
+		return start;//if the two lines are the same, then return the starting point
+	//No case is set for paralell lines that do not lie on top of each other because in the
+	//context that this was designed, this should never occurr, as that would imply that the
+	//control point that this is used to find cannot be plotted (+-infinity).
+	else
+	{
+		Point out;//declair an output variable
+		out.y = -(l0.A * l1.C - l0.C * l1.A) / (l0.A * l1.B - l0.B * l1.A);//find y
+		out.x = ((-l0.B * out.y) - l0.C) / l0.A;//find x
+		return out;//return the intersection point
+	}
+}
+
+void pathCurve(pList *path, unsigned short res = 32)
+{//primary function to control the bezier curves generated to follow the path with each curve
+//having <res> segments
+//memory address of first node in the linked list of the path required
+//set the color desired for the Bezier curve before calling this function
+
+	pList* end = path;//find the address of the ending node
+	while(end->link != NULL)
+		end = end->link;
+
+	if(path == end)
+		return;//if there is only one point or no points, then do nothing
+	if(path->link == end)
+	{//if there are only two points in the path, then draw a straigt line
+		glBegin(GL_LINES);
+		glVertex2f(path->stone.x, path->stone.y);
+		glVertex2f(end->stone.x, end->stone.y);
+		glEnd();
+	}
+	else
+	{//draw a curve
+		float a, b, c, theta;
+		Line l0, l1;
+		Point ctrl;
+		Point arc, arc0;
+
+		//To find the control point for the first curve, imagine a triangle formed by
+		//The first three points in the list, where the sides connected to the beginning
+		//point are a and b and the side opposite the beginning point is c.
+		a = dist(path->stone, path->link->stone);
+		b = dist(path->stone, path->link->link->stone);
+		c = dist(path->link->stone, path->link->link->stone);
+		//use the law of cosines to find the angle formed by a and b
+		//the function is going to create a line, (not plotted), that will be the third
+		//point on the path rotated twice the value of the angle a b and then its 
+		//intersection with the perpendicular line to a will be the control point
+		theta = 2.0 * acos((a * a + b * b - c * c) / (2.0 * a * b));
+
+		//to deturmine which direction to rotate b, create an end point for both rotations and
+		//use the point which is closer to the second point on the path
+		arc = Point(path->stone.x + b * cos(acos((path->link->link->stone.x - path->stone.x) / b) + theta), path->stone.y + b * cos(acos((path->link->link->stone.y - path->stone.y) / b) + theta));
+
+		arc0 = Point(path->stone.x + b * cos(acos((path->link->link->stone.x - path->stone.x) / b) - theta), path->stone.y + b * cos(acos((path->link->link->stone.y - path->stone.y) / b) - theta));
+
+		if(dist(arc, path->link->stone) > dist(arc0, path->link->stone))
+			arc = arc0;//if arc0 is closer to the second point, then copy it to 
+				//the variable arc, which will be used
+
+		l0 = Line(path->stone, arc);//create a line from the beginning point to arc, (the
+					//rotated value of the third point in the path)
+
+		for(pList* p = path; p->link != NULL; p = p->link)
+		{//for all nodes, p, in the linked list such that there is a node that comes after p:
+			l1 = Line(p->stone, p->link->stone);//make a line from p to the next point
+
+			//these 6 lines plot the line from p to p->link in cyan and then resets the
+			//color of the curves to orange
+			//they are only here for debugging purposes
+			glColor3ub(0, 255, 255);
+			glBegin(GL_LINES);
+			glVertex2f(p->stone.x, p->stone.y);
+			glVertex2f(p->link->stone.x, p->link->stone.y);
+			glEnd();			
+			glColor3ub(231, 64, 0);
+
+			ctrl = intersect(p->stone, l0, l1.perp());//find the control point for the curve
+							//as the intersection of the perpendicular
+							//line to the path and the last line used in
+							//gererating a curve, (simulated for the first curve)
+			l0 = qbCurve(p->stone, ctrl, p->link->stone, res);//draw the curve with the control
+									//point and get back the last line
+									//used
+		}
+	}
+	return;
+}
+
+void drawMe()
+{//example function for the above code
+	glClear(GL_COLOR_BUFFER_BIT);//clear the buffer
+
+	//plot the example points
+	plot(a);
+	plot(b);
+	plot(c);
+	plot(d);
+	plot(e);
+	plot(f);
+
+	glColor3ub(231, 64, 0);//set color for the curve
+
+	//call the function pathCurve for a path
+	//pathCurve(&w);
+	pathCurve(&p);
+
+	SDL_GL_SwapBuffers();//dispaly the drawing in the buffer
+	return;
+}
+
+int main()
+{//example program for testing the bezier curve functions for Sprouts
+	SDL_Event event;
+
+	if(SDL_Init(SDL_INIT_VIDEO) < 0)
+	{
+		fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
+		exit(1);
+	}
+	atexit(SDL_Quit);
+
+	SDL_Surface *screen;
+
+	screen = SDL_SetVideoMode(600, 600, 24, SDL_OPENGL);
+	if(screen == NULL)
+	{
+		fprintf(stderr, "Unable to set xSize X ySize video: %s\n", SDL_GetError());
+		SDL_Quit();
+		exit(1);
+	}
+
+	glMatrixMode(GL_COLOR);
+	glLoadIdentity();
+	glOrtho(-30, 30, -30, 30, 0, 1);
+	glMatrixMode(GL_MODELVIEW);
+	//glEnable(GL_DEPTH_TEST);
+
+	glLoadIdentity();
+	drawMe();
+
+	while(true)
+	{
+		while(SDL_PollEvent(&event))
+		{
+			switch(event.type)
+			{
+			case SDL_KEYDOWN:
+				switch(event.key.keysym.sym)
+				{
+				case SDLK_ESCAPE://if esc, then quit
+					exit(0);
+				}
+				break;
+			case SDL_QUIT://X button on the window
+				exit(0);
+			}
+			usleep(40);
+		}
+		usleep(40);
+	}
+}
+Mercurial Distributed SCM
+
+list of commands:
+
+ add          add the specified files on the next commit
+ addremove    add all new files, delete all missing files
+ annotate     show changeset information by line for each file
+ archive      create an unversioned archive of a repository revision
+ backout      reverse effect of earlier changeset
+ bisect       subdivision search of changesets
+ branch       set or show the current branch name
+ branches     list repository named branches
+ bundle       create a changegroup file
+ cat          output the current or given revision of files
+ clone        make a copy of an existing repository
+ commit       commit the specified files or all outstanding changes
+ copy         mark files as copied for the next commit
+ diff         diff repository (or selected files)
+ export       dump the header and diffs for one or more changesets
+ forget       forget the specified files on the next commit
+ grep         search for a pattern in specified files and revisions
+ heads        show current repository heads or show branch heads
+ help         show help for a given topic or a help overview
+ identify     identify the working copy or specified revision
+ import       import an ordered set of patches
+ incoming     show new changesets found in source
+ init         create a new repository in the given directory
+ locate       locate files matching specific patterns
+ log          show revision history of entire repository or files
+ manifest     output the current or given revision of the project manifest
+ merge        merge working directory with another revision
+ outgoing     show changesets not found in the destination
+ parents      show the parents of the working directory or revision
+ paths        show aliases for remote repositories
+ pull         pull changes from the specified source
+ push         push changes to the specified destination
+ recover      roll back an interrupted transaction
+ remove       remove the specified files on the next commit
+ rename       rename files; equivalent of copy + remove
+ resolve      redo merges or set/view the merge status of files
+ revert       restore individual files or directories to an earlier state
+ rollback     roll back the last transaction (dangerous)
+ root         print the root (top) of the current working directory
+ serve        start stand-alone webserver
+ showconfig   show combined config settings from all hgrc files
+ status       show changed files in the working directory
+ summary      summarize working directory state
+ tag          add one or more tags for the current or given revision
+ tags         list repository tags
+ tip          show the tip revision
+ unbundle     apply one or more changegroup files
+ update       update working directory (or switch revisions)
+ verify       verify the integrity of the repository
+ version      output version and copyright information
+
+additional help topics:
+
+ config       Configuration Files
+ dates        Date Formats
+ patterns     File Name Patterns
+ environment  Environment Variables
+ revisions    Specifying Single Revisions
+ multirevs    Specifying Multiple Revisions
+ revsets      Specifying Revision Sets
+ diffs        Diff Formats
+ templating   Template Usage
+ urls         URL Paths
+ extensions   Using additional features
+ hgweb        Configuring hgweb
+ glossary     Glossary
+
+use "hg -v help" to show aliases and global options