• Create Account

Member Since 01 Feb 2004
Offline Last Active May 03 2015 08:46 AM

### How do I find collision intersection point(s) using EPA?

13 April 2015 - 03:11 PM

I've implemented 2D collision detection using the GJK and EPA algorithms which provides the intersection normal and penetration depth, but to implement decent collision response I need to find the intersection point.

I've been searching for the answer for a while now but I can't find anything. Could someone explain how to find the intersection point?

### Rotate to face a direction, by applying angular acceleration?

16 December 2013 - 12:41 PM

This seems like it should be simple, but I've been struggling with it for a while.

I have a starship that has an associated ODE body. I'm trying to get the starship to follow a path. So I calculate the desired heading as a vector.

The problem is I need to find the angular force to apply (as a vector) to rotate the ship from its current heading (forward vector) to face the desired heading.

Could someone explain how to calculate that angular force?

### Using a PID controller for heading, what error value to use?

13 December 2013 - 02:22 AM

I'm working on some basic AI for a fighter game, and I'm trying to get the ships to fly into a formation. To calculate the amount of torque I need to apply to each ship so that it turns towards the desired heading I'm using a PID controller very similar to the one in the first answer here: http://answers.unity3d.com/questions/199055/addtorque-to-rotate-rigidbody-to-look-at-a-point.html

So, I have the current heading of the ship, and the desired heading, and I need to pass an error value into the PID controller so that it can correct the heading.

In the linked example, the poster uses the cross product of the desired heading and current heading. This works perfectly if the angle between the headings is < 90 degrees, if it's greater than 90 degrees then the cross product is flipped and the PID controller starts correcting to the opposite direction than I want!

I'm struggling to figure out what vec3 error value will work in all cases, even if there is a large angle between the desired and actual heading. Any ideas?

### Kazmath, a C math library

14 August 2008 - 02:06 AM

Hi all, For a while now I've been building up a little 3D math library written in C. Recently Carsten (the other NeHe maintainer, and general math genius) has been contributing too. Its NOT FINISHED and hasn't been tested thoroughly (unit tests are next on our list) but if any of you feel inclined I would appreciate feedback, patches, suggestions, feature requests etc. You can find it under browsable GIT version control here: http://github.com/Kazade/kazmath/tree/master Currently there are only build files for Linux using cmake, (that is only because I haven't got round to writing a cmake file for Windows yet, if anyone fancies implementing one, feel free), there are no other dependencies. Any patches should be sent to kazade AT gmail Dot Com with the subject "Kazmath" or "Patch" or something. Let me know what you think [smile] Luke. PS. I am aware that git doesn't easily work on Windows, so when I have time I will migrate to a more Windows-friendly version control system.

### Templates and variable names

14 January 2008 - 07:04 AM

Hi, I've had an idea on the train home for my engine, but before I get too carried away with it I'd like to know if something is possible with C++ templates... Imagine I have a class like this:
```template< typename T, typename U >
class MyClass {
public:
T var1;
U var2;
};
```
When I instantiate it I can do something like this:
```MyClass<House, Car> someInstance;
//here I can access someInstance.var1
```
What I want to do is name the member variables using some kind of ID from the passed in objects. So, for example..
```template<typename T, typename U>
class MyClass {
T  T::someID; //someID here is house when instantiated below
U  U::someID; //someID here is car
};

MyClass<House, Car> someInstance;
//here I can access someInstance.house and someinstance.car
```
Now, I want to use this for something a lot more complicated than that, but that's the simple case that I want to achieve. I could do something using a map<string, boost::any> and do someInstance.m_map["car"] but I want to move the lookup from runtime to compile time. I know this must be possible (or something equivalent) somehow, I just don't know how [smile]

PARTNERS