Posts Tagged ‘geometry’


quaternions page is up + good times

September 29, 2008

Let me get this out of the way – there is a new article about quaternion rotations up.  Yes, I know I haven’t showed you how to convert to/from them, so it’s useless except as a theoretical paper.  This will soon change, but TOMORROW.  GOD IM TIRED BLARG.

Also to get out of the way, 2D Boy is almost about to release World of Goo, which I’m really geeking about right now.  If you order before they release it, you get a profanity sound effects pack.  FUCK!  😀

So I’ve had some good times this past week, which is interesting, seeing as how it literally started out with me on suicide watch.  I made a full recovery on Tuesday, ironically because of a Dream Theater song I was listening to.  A Change of Seasons, and there’s this part that’s like “I’m sick of all you hypocrites!  I don’t need your sympathy to get me through the day! Seasons change, and so can I!…” and it was really inspiring.  My main problem, I suddenly realized, was in expecting sympathy for my problems.  Whereas in a perfect world I would certainly get some sympathy for the kind of shit I deal with, I realized expecting it from everyone will only make me feel let down.

Then I went skating on Thursday with James, Colleen, and Phillip on 80’s night, and we listened to music from the past (i.e. real music) the whole time while skating.  On Friday I saw James again, and we basically played Destroy All Humans and such the whole time, but after that we went back to the rink on Saturday and enjoyed a roller derby match!  Go RoCo!  That was actually a really good time.  Then the next morning I went to YRUU (that’s youth religious unitarian universalists) again and didn’t get picked on really by that girl, so it was actually pretty cool.  I had a long conversation afterwards with cool people who like Transformers, Spore, D&D, and other incredibly geeky stuff, making me feel at home.  Tomorrow Chuck and Life are on network television, followed by a Tuesday at programming club, where I really just can’t feel better.  I’m on a roll of engaging in non-suckage!  😀

But my point is, I really forget just how much I can do when I’m in good spirits.  I wrote that whole fucking quaternions article in about an hour!  I mean, that is just crazy fast.  Of course it’s not quite finished, but I could have easily just slapped all the functions up there, and didn’t.  In fact, it was like a mini paper on quaternions before it even gets to rotation, and then there’s an extensive discussion on that.

When I get up tomorrow, I’ll get straight to work on the menus and hopefully have a usable thing soon.  And then I really will get to work on the game.  I’m still deciding if it should be pure 2D (aside from the menus obviously) or if I should go all slick and shiny 3D interface on you people, with bells, whistles, and cabbage.  All puppies need cabbage to slaughter freemasons!  Ahhh, I’m like, intoxicated with not feeling awful.  I almost forgot what that was like, you know?  ❤


new educational page

September 18, 2008

This is a blog about programming and technology and stuff.  Music and art may come up occasionally, but that’s not really the focus.  Therefore I must not only make an ass of myself by ranting at the world from a pathetic blog, I must also be USEFUL.  So, I’ve decided to keep a seires of pages about various programming topics on here.  I’ve just finished my first.  It’s on spheres, and how to render them without resorting to the dreaded longitude/latitude fiasco.  I give an approach which was detailed in the OpenGL Red Book, but for some reason, no sample that I know of was given.  None that was simple and easy anyway, as everyone is confused about how to do it.  So I did a page with a simple source sample that’s very self explanitory using OpenGL to draw these suckers.  I also went in to a fairly complicated and deep discussion of why latitude and longitude are not only an inefficient rendering approach, but that they are also skewed (which is what makes them inefficient for rendering) and an obsolete coordinate system in general.  Spherical geometry must be used for newer coordinate systems.  Then I explain great circles and how they can be used to… blah blah blah… hull… blah… just read it.  😛


I made it work zomg happy :3

September 17, 2008

I got this sucka working!  That’s right, a sphere NOT MADE WITH LATITUDE AND LONGITUDE.  Great pwn4ge, what is this miracle?  I’ll tell you.  Basically, what I’ve done is taken an icosahedron and recursively subdivided with level of detail.  You may have seen something like this in the OpenGL red book.  But I swear I didn’t see it in there.  I later found out it was in there.  It turned out their method was better than mine, so I went over to optimizing theirs.  I have my result here, and with a precalculated icosahedron mesh for the tesselating.

Here: (sphere.c)

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <GL/gl.h>

#define _A 0.525731112119133606f
#define _B 0.850650808352039932f

static unsigned int icosa_indices[20][3]=

static float icosa_verts[12][3]=

static void normalize_vert(float *a)
float d=sqrtf(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);
a[0]/=d; a[1]/=d; a[2]/=d;

static void draw_recursive_tri(float *a,float *b,float *c,unsigned int div,float r)
if (div==0)


register unsigned int i;
float ab[3],ac[3],bc[3];
for (i=0; i<3; i++)



void rat_draw_sphere(unsigned int detail,float radius)
register unsigned int i;
for (i=0; i<20; i++)


icosahedrons and geodesics

September 17, 2008

Quick post before I leave to get an allergy shot.  I seem to have found a likely solution for my sphere constructing blues.  Basically, an icosahedron, which is very easy to construct, can be subdivided many times and remain geodesic.  This is the method I will try.  I also will provide links to a couple of pages I found useful in my sphere quest.

Aaaannd… I can’t find the other one again.  Booooo.

Gotta go.


Opeth wins, still having sphere trouble

September 17, 2008

Opeth‘s newest album is Watershed, and I just got the opportunity to listen to it.  This thing is incredible, definitely Opeth‘s most ambitious and heavy album yet.  It has a lot more stuff in it that seems to be in metal’s more extreme sub-genres, and yet touches on music which is even more beautiful than any purely acoustic or otherwise soft things they’ve done.  There are parts that even reflect elements of jazz and psychedelic rock.  This album is pure poetry.  I highly recommend it.

And back in apple dancer land, the insane asylum where my happy goat lives, I’m still having trouble with the whole great circles sphere tessellation thing.  I refuse to fall back on lattitude and longitude circles because I’m an efficiency whore.  I’ll get this thing.


possible new pages and game menu sphere trouble.

September 17, 2008

I’m having mega trouble with this sphere business.  I have been trying to create my own version of the menus in Metroid Prime 2.  If you played that, you know these menus are totally sweet, and consist of a hub in the middle with spokes coming out as menu items.  You rotate this hub in 3D, and the front most option is what is selected.  I’m making a more solid version with cylindrical spokes (easy) and a sphere in the middle (hard.)  You’re probably thinking, “why doesn’t this idiot just use latitude/longitude for his sphere?”  Because it’s not as efficient as a geodesic sphere.

Now, by my understanding, the best method for triangular tessellation of a sphere is simple.  Basically, we have several arrays of longitudinal looking great circles, each one with a different pole pair.  The intersection of three great circles then is a triangle on the surface of the sphere.  Problem is, I have no idea how to store and calculate the intersections of these great circles, even though I have a perfect understanding of the geometric concept.

Fig. 1

Fig. 1

Fig. 1 shows a great circle.  That green plane intersects the center of the white sphere forming the red great circle.  So, it’s not that hard of a concept.

But do we store the plane’s information, or the circle’s?  It makes sense to me we should store the plane’s information with an orientation matrix (or other orientation representation) for the plane.  So that’s out of the way.

Now, in Fig. 2, we see what a great circle array looks like.  This is what I want each pole pair to have.

Fig. 2

Fig. 2

This is actually an image of the longitudinal lines on a lat/lon method sphere, such as a planet.  These are actually, like I said before, a great gircle array.  Now imagine a set of these, each with one pole originating from the vertex on a tetrahedron.  This is a perfectly triangle tesselated sphere.  I am really having trouble with the geometry math on this though, and would appreciate any help.  If I get this working, I will do a page in the blog pages for it.

Speaking of pages, I am thinking of creating a blog page about text rendering in OpenGL.  This will include instruction of how to load freetype fonts and how to display texture fonts.  I will discuss the converting of the alpha-luminance bitmaps given by freetype in to power of two 8 or 4 bit alpha textures, and how to make and load pure bitmap fonts.  Then displaying the textures with a simple function.  I’ll also cover metrics.  But only if it’s requested.  Or if I feel like it.