# Gorwooken

Member

43

1. ## Circular Interpolation

maybe someone can tell me if this makes sense i'd like to interpolate using distance rather than time so i'll solve for t so theres dtheta/dt = v/r + (aT/r)*t then theta = (v/r)*t + (aT/2r)*t^2 so now i'll assume i'm starting at a point on the circle so x = rcos((v/r)*t + (aT/2r)*t^2) y = rsin((v/r)*t + (aT/2r)*t^2) and (aT/2r)*t^2 + (v/r)*t - acos(x/r) = 0 (aT/2r)*t^2 + (v/r)*t - asin(y/r) = 0 and i take the positive root so if i start at (r, 0) on the circle and i rotate to (0, r) with v = 0 then t = sqrt((acos(x/r)*2r)/aT) t = sqrt((asin(y/r)*2r)/aT) now at (0, r) the velocty in x is Vtangential y is 0 if i swap the sin and the cos out when i pass 90 degrees (aT/2r)*t^2 + (Vtangential/r)*t - asin(x/r) = 0 (aT/2r)*t^2 + (Vtangential/r)*t - acos(y/r) = 0 then i continue to recalculate the tangential velocity and swap the sin/cos every 90 degrees, is this correct?
2. ## Circular Interpolation

I'm developing some software for driving stepper motors. I'm a little stuck on some of the math behind circular interpolation. I'm finished with linear interpolation and i went about that by using d=a/2t^2 i can move distance s every time i step so d = s*n where n is the number of steps i've taken. t = sqrt((s*n/a)*2) then my dt = sqrt((s*n/a)*2) - sqrt((s*(n-1)/a)*2). initially i looked into doing something similar with circular interpolation but since arctan isn't a 1 to 1 function i lost my way basically i want to start a v = 0 and accelerate at some tangential velocity aT, so the parametric forms for a circle are: x = a + rcos(theta) y = b + rsin(theta) and d^2theta/2t^2 = aT/r so theta = (aT*t^2)/(2*r) and we have x = a + rcos((aT*t^2)/(2*r)) y = b + rsin((aT*t^2)/(2*r)) now obviously if i wanted to solve for t the constraint on x is -r <= x <= r and this is where my problem lies i need to be able to incorporate the rotation. ie i start at r and move to -r on the x axis, but if i want to go from -r to r then to 0 i don't know how to express that. my current implementation interpolates using t then calculates the change in position if that is >= to my step distance, i use that delta t. this feels very inefficient but it does seem to work, is there a more elegant solution?
3. ## Circular Interpolation

in this particular problem i need to generate a set of values that will allow me to ramp up to a specific tangential velocity then maintain that velocity. i do agree that that would solve the problem if i wanted to look at it as a straight line but i don't i suppose i should have stated that this is a coordinated motion problem, i have a stepper motor controlling x, and one controlling y i can step s in a either direction along that axis i need to generate a list of times for each axis that when i step the motors at those intervals generates a circle
4. ## IN and OUT

i've been playing around with some driver development for windows. I've noticed a few issues with IN and OUT. Currently just for my own amusement i'm working on serial port driver that communicates with the UART chip on port 0x3F8 (com 1). I've noticed that when I run my driver anything i read from the registers returns 0xFF unless something in windows has an open handle to a serial port in which case it returns the proper value of what i wrote to it. Also I've noticed that i can't set PIC masks on port 0x21, i can only ever read back 0 from there ( all interrupts enabled ). I've done some interfacing with an APIC before and I've had no issues working with interrupt masks. Is there an ability to disable access to certain ports that I'm unaware of? I'm just looking for an explanation.
5. ## FSB Frequency

I was hoping it was stored somewhere in windows but i decided to just calculate it when my driver launches. If anyone is interested I use QueryPerformanceCounter to calculate the time it takes for the APIC timer to count down from 0xFFFFF to 0 at the bus' frequency. I then calculate the FSB freq. I'm still open to other ideas if there are any.
6. ## FSB Frequency

I'm working on a windows driver that enables and and installs an interrupt handler for a cpu's local APIC timer. According to the intel manual the apic timer freq is derived from the FSB frequency so I'm looking for a way to obtain that freq in windows. any suggestions would be appreciated.
7. ## Executing a command line from the code

If you want to play the mp3 in the default windows mp3 player, you should use ShellExecute It performs the same function as if you were to type something into Start->Run
8. ## Arrays in C

I'm working on some software for a motorola processor and i'm developing it in C. I'm trying to keep my code as small and maintainable as possible. Currently I'm implementing a circular buffer, however I'd like to be able to store any datatype in this buffer. I was thinking of doing something like this: typedef struct { void *pData; word ReadLoc; word WriteLoc; word nElements; word nSize; size_t nWidth; } CBUFFER; bool buffer_write(CBUFFER* pBuffer, void *pData) { //if space is avail word nWidth = pBuffer->nWidth; if(pBuffer->nElements < pBuffer->nSize) { memcpy(((byte*)pBuffer->pData)[nWidth*pBuffer->WriteLoc], pData, nWidth); pBuffer->nElements++; pBuffer->WriteLoc++; // check to see if out of bounds, set to 0 if it is return TRUE; } // no space return FALSE; } CBUFFER* buffer_create(word nSize, size_t nWidth) { CBUFFER *pBuffer = (CBUFFER*)malloc(sizeof(CBUFFER)); if(pBuffer) { memset(pBuffer, 0, sizeof(CBUFFER)); pBuffer->nWidth = nWidth; pBuffer->nSize = nSize; pBuffer->pData = malloc(nSize*nWidth); if(pBuffer->pData) return pBuffer; free(pBuffer); } return NULL; } void main() { somedatatype data = something; CBUFFER *pBuffer = buffer_create(60, sizeof(somedatatype)); buffer_write(pBuffer, data); // and so on.... } I just wrote that up so don't bother checking for syntax, I also may change the create function to take a pointer to a CBUFFER structure so i can allocate the structure on the stack if i want to. Other operations would be implemented in a similar way. I was just wondering if there are any better ways to go about doing this?
9. ## Microprocessor Operating System Messages

I've been developing a multitasking operating system for a 16 bit motorola processor, everything so far is going well, the software task switching works and is stable. Now I'm looking for a way to get information from an interrupt to running processes. I need to do the least amount of work in the interrupt itself, just unload the data somewhere. I was thinking about passing messages off to a circular buffer in the kernel and allowing the kernel to process the messages and pass them off to processes when it gets cpu time. I want messages to have a priority aswell, what would the fastest way to go about this? just use a circular buffer for each priority level and empty them out based on priority?
10. ## Singleton Help!

You don't really need to use a singleton, you could just pass it like this Just pseudo code class Path{ public: Path(Print *print); ~Path(); SetPath(); .... .... Print *m_pPrint; }; Path::Path(Print *print) { m_pPrint = print; } Path::SetPath() { ...... m_pPrint->Error(); ...... } Print g_print; void main() { Path path(&g_print); path.Print; } or you could just access the global from the constructor Path::Path() { m_pPrint = &g_print; }
11. ## Please point me a good 'GJK algorithm' article

I've read through ginos material. Most of it was straight forward, it helped me do the implementation for penetration depth. I wrote the algorithm out a few months ago, still a couple of bugs I need to sort out I just haven't had the time. I had previously done an implementation of GJK for separating distance based off Christer's articles which are by far the best out there.
12. ## Tiling sides of 3D triangle

If I understand you correctly you simply want to create a wedge with 6 vertices. When you say 3 quads high and 5 deep I'm a little unsure of what you want. If you always want it to be a simple ramp you'll only ever need 3 quads and 2 tris. if you want to create a ramp thats 3 units high and 5 units deep i'd suggest beginning at the origin for simplicity. Create a vertex at the orign, create another 5 units along the x axis and another 5 units above that so you have 3 verts. (0, 0, 0), (5, 0, 0), (5, 0, 3) now offset these along the y axis by the width you want (0, W, 0), (5, W, 0), (5, W, 3) and create 2 tris using each of those set of points(sides) and the rest can be quads.
13. ## How does the following code work

Well i'm pretty sure the compiler will truncate x = 260 and after the truncation you'll be left with x equal to 4. unsigned char is one byte and you've got 260 which is 100000100 in binary since one byte represents 8 bits a truncation will leave you with 00000100 which is 4, then you shift 4 to the left twice, 16, then you and 16 with 15, resulting in zero and the not of zero is one. The code "works" but you realy shouldn't be assigning numbers to data types that can't store them.
14. ## Penetration Depth

I've been reading Gino's paper here and I've understood most of it however I'm still unsure of exactly how hes going about splitting a triangle while inserting a new point. He tests the edges to see if they lie on the minkowski difference, if it does he doesn't split it, however if it doesn't where exactly does the split occur along the edge?
15. ## Penetration Depth

I'm having a couple issues when it comes to my function layout in terms of building these triangles, I'm breaking most of it up into cases. Say the point on the sum in the direction of closest point on the face of the triangle returns as one of the vertices of the initial triangle. I'll end up building degenerate triangles. I'm trying to avoid this. I've got 2 main cases set up, one if the above is true, if its false I take another path that checks if any of the points found on the sum in the direction of the closest point on the edge lie on a vertex of the initial triangle. I'm worried that this is a little excessive. I've finished an implementation of the GJK algorithm for computing separating distance. I've noticed numerical imprecision as the distance between objects gets very large but generally I use SAT with OBBs to determine if two objects could possibly be intersecting then switch to GJK as a second test. For the most part it gives me fairly good results.
16. ## Penetration Depth

I'm still a little stuck on this, I'm unsure of what to do with the face of the triangle I'm splitting. I've got something working but its somewhat unstable at the moment I'm not sure on how to terminate the algorithm.
17. ## Penetration Depth

So for each edge of the triangle I find the point closest to the origin and find the associated point on the minkowski difference in the direction of that point and use these points to split the edges? Is the same also done for the face of the triangle?
18. ## Getting the True Bearing between 2 points. [Still Not Working]

Can't you just reassign your point B to be equal to the current mouse location? I don't see why this wouldn't work, if A was your achor point and B the mouse location you'd always be drawing a line from A to the current mouse location. If not, if you're looking for an angular relationship b/w the lines AB and AX and then take the dot product b/w these two lines. Take the direction vector of AX and dot it with the direction vector of AB, so you'd have acos(AX/|AX|*AB/|AB|) where || is the length of the vector and * is the dot product. The dot product is defined as |AX|*|AB|Cos(T) = AXx*ABx + AXy*ABy so to solve for T you'd divide by the length of AX and AB and take the arccos of both sides.
19. ## Getting the True Bearing between 2 points. [Still Not Working]

Is your code trying to calculate the amount to rotate the line to face X? Are you trying to do some interpolation to animate the line rotating from line AB to AX? I'm still not quite following, couldn't you just create a new line (Ax, Ay), (MouseX, MouseY) every time you detect the mouse moving and draw that line to the screen?
20. ## Getting the True Bearing between 2 points. [Still Not Working]

I'm not sure what your problem is here, you've got the direction vector from A to B being the vector X, your diagram appears to be correct. The direction vector in this case is the length and direction of how to get to point B from point A.
21. ## Simple unit movement

Quote:didn't stop and it wouldn't move the other direction (because normalize always results in a positive number). Are you saying that everytime you normalize a vector it comes out with all its components positive? I'd take a look at your code for normalize, you're only ever dividing your vector by a positive number, its will retain its direction.
22. ## Barycentric Coords

TI'm not sure if theres a better way to do it but when i needed to calculate barycentric coords i decided to write a function for row reduction for my matrix class, since all we're looking for is a solution to a system of linear equations. W1A + W2B + W3C = D so i have 3 points of the triangle, A, B, C and the point that i want to represent, D. I setup the matrix like this: | Ax Bx Cx | Dx | | Ay By Cy | Dy | | Az Bz Cz | Dz | | 1 1 1 | 1 | The last row there is the formula W1 + W2 + W2 = 1. Now I have 3 weights that I want to solve for, the coeff for W1 are the left most column, W2 the one to the right of that ect. All I do now is put this matrix into row reduced echelon form and i've got: | 1 0 0 | W1 | | 0 1 0 | W2 | | 0 0 1 | W3 |
23. ## BSP

You could cast a ray from your player directly down and test for an intersection against your level. Knowing the point on your players feet and the intesection point of the ray and the triangle you can determine how high you are off the ground.
24. ## Point on a Tetrahedron to a point

What is the best method for finding the closest point on a tetrahedron to a point? I've implemented a method for finding the closest point on a triangle to point using voronoi regions, should i just find the closest point on each of the triangles and return the point on the triangle that has the shortest distance to my test point? Seems like there should be a better way.
25. ## probability problem

I'm not too familiar with probability but you're integral would be F(x) = -e^(-kx) + C. since the the derivitive of e^(exponent involving x) is just the original function multiplied by the derivitive of the exponent with respect to x