I'm making a list of locations that will need to be 6 yards apart each. I have a start and end point. I'm using atan to get the angle for the right triangle. I was hoping someone could point me in the right direction to finish this up.
I'm making a list of locations that will need to be 6 yards apart each. I have a start and end point. I'm using atan to get the angle for the right triangle. I was hoping someone could point me in the right direction to finish this up.
Um, so you're trying to get the angle between your current facing direction and the next location in a list? More details please.
No, I have no problem finding angle etc. I am having issues making the list of locations itself. I have a start and end location, but I need to find points in between at 6 unit increments.
implement a A* path finding. Google, and to get waypoints 6 yards apart check the distance from each waypoint to the next
You really gotta be more specific. Is it supposed to be a staight line? There's an infinite number of ways to connect 2 points.
If it's supposed to be a straight line:
Point A(xa,ya,za) and point B(xb,yb,zb).
v = (xb-xa,yb-ya,zb-za) = (xv,yv,zv)
n = sqrt(xv^2 + yv^2 + zv^2)
w = 1 / n * v
OP[ i ] = OA + 6i * w = P[ i ] // P[ i ] is the i-th point that is 6*i yards away from point A into the direction of AB.
I think that's what I was looking for. I needed a straight line. +rep.
EDIT: I'm guessing that last part, OP[ i ] = OA + 6i * w = P[ i ], will have to be a matrix?
Last edited by lanman92; 07-02-2009 at 12:55 PM.
Then theres another question, Im tired but cant figure out why you need several waypoints on a straight line...
(Its 0437. Tired. Excuse errors.)Code:void getPointsBetween(Vec3f a, Vec3f b, Vec3f *Points[]) { Vec3f v = a - b; float n = sqrt(v.x*v.x + v.y*v.y + v.z*v.z); Vec3f w = (1 / n) * v; // = Vec3f( (1/n)*v.x, (1/n)*v.y, (1/n)*v.z ); #define STEPSIZE 2 int numPoints = n/STEPSIZE; Points = new Vec3f[numPoints]; for( int i = 0; i < numPoints; i++ ) { Points[i] = a + ((STEPSIZE*i)*w); // = Vec3f( a.x + STEPSIZE*i*v.x, a.y + STEPSIZE*i*v.y, a.z + STEPSIZE*i*v.z ); } }
Last edited by schlumpf; 07-02-2009 at 09:38 PM.
Thank you very much schlumpf
EDIT: Anyone know how to make your window stay on top when you select WoW? It's an injected form through clr hosting, and topmost property doesnt work. Tips?
Last edited by lanman92; 07-02-2009 at 10:06 PM.
Use p/invoke to call SetWindowPos. SetWindowPos Function ()
Pass HWND_TOPMOST to the second argument, hWndInsertAfter. HWND_TOPMOST can be defined as -1 *I think*.
Of course, none of this may work.. I haven't tested it.
I'm pretty sure that won't work, but I'll give it a shot I have to imagine that this is the API that .NET uses internally.
Nope, didn't work
Last edited by lanman92; 07-03-2009 at 12:28 AM.
I've set my WoW to windowed and maximized, and my app to stay ontop, works fine for me. but that's not what you really want I assume
No, it's because my form is created behind WoW in z-order for some reason. It wants to stay that way. I've been looking for a way to draw a form onto a directx control or something... No avail yet.
By behind in z-order, I mean that my window is a child of WoW and it wants to be in front. lol.
Just wanted to point out to anyone who wants to use code based off this there are some things you need to keep in mind:
The vectors are heap allocated and hence need to be manually deleted. To avoid this problem use a shared_ptr.
The way the data is returned is also potentially more dangerous than it needs to be. You're better off either making the function take a vector by reference, or take an insertion iterator. The most obvious candidate for the latter being a back_inserter. The advantage of an insertion iterator is that you can generalize the algorithm so that it's not container-dependent.
Also, if you're dealing with large data sets you might want to catch bad_alloc exceptions in-case 'operator new' throws (or if your C++ implementation uses a nothrow new implementation then do a null check), then return a boolean indicating whether the operation succeeded or not.
Yep, that's been a very ugly one. Its more C than ++. Ugly and dangerous, but at least working. ^^