Jump to content

  • Log In with Google      Sign In   
  • Create Account

RAZORUNREAL

Member Since 17 Jan 2004
Offline Last Active Aug 19 2013 11:52 PM

Topics I've Started

Tetrahedral interpolation

26 November 2007 - 08:07 PM

I'm working on a voxel renderer (have a look if you want) and an important part of the algorithm is 3d interpolation. As in, without the interpolation it doesn't work properly. I'm not too worried about the quality, it just has to be there. At the moment I'm using trusty old trilinear interpolation, but I've been looking at alternatives. The most interesting alternative I've found so far is tetrahedral interpolation, which would let me halve the number of lookups, thereby greatly improving performance (I hope). Unfortunately, the only descriptions I've found of it are either in legalese or cost money. I've found out enough that I think I could work out how to interpolate between the 4 points of the tetrahedron. I have no idea if it can be done fast, but that's a question for another day. What I want to ask about is how you divide a cube into tetrahedrons and, having done that, how you quickly determine which tetrahedron a point is in. I came up with a way of dividing a cube into 5 tetrahedrons (at least, I think I did), but in my search I came across a way of dividing one into 6, which all share a common edge (a diagonal through the centre). I'm still trying to get my head around how both are possible, and which would be simpler. To determine which tetrahedron a point is in, all I've come up with is checking against the plane equations. For example:
if (x + y + z < 1)
   // Interpolate points (0, 0, 0), (1, 0, 0), (0, 1, 0) and (0, 0, 1)
else if (other equations)
But I doubt that would compare performance wise with trilinear. Any ideas? Oh, one last thing, I did have the idea of replacing my cubic grid with a tetrahedral one, but I don't know if it's practical or worth it.

Projectile motion

03 October 2006 - 07:08 PM

I'm attempting to find the angle to fire a projectile at such that it lands at a specific point. I have only done (in fact, I havn't even completed) high school level physics and calculus, so please bear with me. Here's what I've done so far: T is the angle fired at (for lack of a theta) Vx is initial horizontal velocity Vy is initial vertical velocity s is the initial speed of the projectile t is time d is horizontal distance to target h is difference in height of target
Vx = cos(T).s
Vy = sin(T).s
d = Vx.t
t = d/Vx
t = d/cos(T)/s
h = Vy.t + 1/2.a.t^2
h = sin(T).d/cos(T) + 1/2.a.(d/cos(T)/s)^2
h = sin(T).d/cos(T) + 1/2.a.d^2/cos(T)^2/s^2
h = tan(T).d + 1/2.a.d^2/cos(T)^2/s^2
So if I could solve that last equation and find T, I'd be pretty much done. But I'm not sure how to do that, and for all I know I'm barking up entirely the wrong tree anyway. Also, if it's not possible to hit the target point, it would be nice to find the angle that comes closest. But it's not essential, I can just set it to 45 degrees and call that good enough. Thanks.

Critique my catapult

08 July 2006 - 01:45 AM

First off, I'm not an artist by any stretch of the imagination. I'm a programmer (meaning this is programmer art) and I'm only 17. But I spent a lot of time making this catapult for my 4E5 entry (like 4 full days) and I'm quite proud of how it's turned out. Here's a shot of it in my game engine: Catapult And here's one from blender, so you can see the texture without lighting: Free Image Hosting at www.ImageShack.us It's 851 triangles with a 512 by 512 texture. I'd really appreciate some advice on how to make it look better.

Template classes in container

22 June 2006 - 11:03 PM

I'm having problems creating a map of templated classes. It seems to have no problem with the map itself, but doesn't like iterators for it. Here's as simple as I can get it:
template<class T>
class A
{
};

template<class T>
class B
{
	std::map<int, A<T> >::iterator iter; // error: expected ';' before "iter"
};

It's weird, because I seem to be able to use iterators returned by the map. I guess I'm just declaring them wrong somehow. Oh, and I'm using mingw. Thanks!

JIT compiled scripting language features

11 January 2006 - 12:03 AM

Hi, I'm working on a JIT compiled scriptingish language thing, and it's got to the stage where need to think about what sort of language it's actually going to be. I'm not sure if it's technically a scripting language, but it's meant to be embedded so it might count... Anyway, I wanted to get some feedback on a few language features. Please bear with me, I havn't had a formal education in this sort of thing yet, so I don't know the terminology and some of my ideas might be naive. I'll endeavor to explain exactly how I plan on doing things, partly because I'm not sure how to describe the features any other way, and partly because I want feedback on the syntax etc. too. Firstly, lets say it's a bit like C or java. Just saying that so you know it's not like some of the more (and even some of the less) obscure languages out there. 1. Any number of named returns I'm thinking of something like this:
(int return1, int return2)Foo(int param1, int param2)
Rather than using eax for return values, which only works for things 32bit or less anyway, I thought I could pass them by reference. And I might as well pass the parameters by const reference while I'm about it, and throw pass by value out the window. So, that would make the above equivelant to the c++ snippet:
void Foo(int& return1, int& return2, const int& param1, const int& param2)
2. All variables must be initialised I can't think of a time where saying a variable = 0 when you create it isn't possible, and uninitialised variables can cause bugs. And honestly, I think leaving a variable uninitialised is a pretty pointless micro optimisation. Especially when my language is already overkill, and is only going to get more so because I can compile it to the system, using things like sse if available. But I'm getting off topic. The real point is it makes feature 3 easier. 3. Type inference/template replacement Basicly, a var type that can be anything. This could cause alot of pain, and for all I know it's impossible, but it would just be so handy. It goes like this:
(var result)Square(var num)
{
   result = num * num;
}
Basicly, the compiler generates a new function each time it encounters a call using a different type. Pretty much like a template function, only not inlined. Pretty much like this template function in fact:
template<class T, class U>
void Square(T& result, const U& num)
{
   result = num * num;
}
Of course you could end up generating huge amounts of code without even noticing, but that's really the point in it anyway... One thing that you can't normally do is:
var someVar = templateFunc(someOtherVar);
Forcing variable initialisation means you can't give a var different types based on some run time condition, which would make my head explode. If you can think of any flaws with all this I'd be very grateful. 4. Custom operators The language should be flexible enough that the program it's embedded into can create new operators etc. But what I'm not sure about is if you should be able to in code... Probably not, given the purpose of the language. Anyway, it would look like this:
operator (vector result)X(vector lhs, vector rhs) : + // Same precedence as addition.
{
   // You all know how to perform a cross product right?
}

vector C = A X B;
For ease of parsing I'd require a space between operators and operands. I was thinking precedence would be set in relation to other operators, rather than a flat value. Like the above operator would have the same precedence as addition. It might also be useful to say an operator has precedence 1 lower than some existing operator. And perhaps if you don't provide any sort of comparison it has the highest precedence. That must be about enough for one day. If this goes well I might be back later with some more unusual ideas, but this post is getting long. So please, any and all feedback. Even if it's just to say that none of this is new (probably true) or it's badly thought out (wouldn't be surprised) or impossible to implement (why please) or X language is better in every way.

PARTNERS