Jump to content


Member Since 25 Apr 2007
Offline Last Active Sep 23 2016 11:04 AM

Topics I've Started

D3DX in Visual Studio 2010 on Windows 7...

26 December 2013 - 01:24 AM

Why use D3DX?

I understand that D3DX is deprecated and replaced by DirectXMath in the Windows 8 SDK.  However DirectXMath is not included in the Windows 7 SDK, and neither is D3DX...which means that there seems to be no "proper way" to access these basic utility functions.  I have heard that it may work to use the Windows 8 SDK for development on Windows 7, however, that doesn't sound entirely reliable to me...and I'm not interested in developing Windows 8 apps at this time anyway.  I would like to utilize some of my older code that is written using D3DX for this project and so I prefer to stick with that for now.  Therefore, I am trying to use the last DirectX SDK frome June 2010.

What's the problem?

After installing the DirectX SDK, and added the new include and lib paths under the Win32.User properties page in Visual Studio (as explained in the answer here ), and add the following includes:


#include <d3d11.h>
#include <d3dx11.h>
#include <d3dx10.h>


#pragma comment (lib, "d3d11.lib")
#pragma comment (lib, "d3dx11.lib")
#pragma comment (lib, "d3dx10.lib")


...and now, although I can use certain D3DX functions like D3DXCOLOR,  I get unresolved external symbol errors for certain functions like D3DXCompileFromFile and D3D11CreateDeviceAndSwapChain. 

I think the problem is that d3dx11.h exists in two places:

C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include
C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include

In other words, the D3DX headers conflicts with the headers already present in the built in windows SDK, and I cannot even remove those built in include paths or give my include path priority over them (at least I don't know how).

How can I resolve this issue?

Kalman filter without using matrix inverse

12 September 2013 - 03:23 PM

Kalman filter predict/update equations are here:



I have implemented the Kalman filter and it works nicely.  However,  the standard Kalman equations are written naively in terms of the matrix inverse.  In particular, the S matrix (innovation covariance) is inverted in order to compute K (the gain matrix):

S = H P H^t + R
K = P H^t S^{-1}

The gain matrix (K) is finally used to update the state estimate (x) and estimated covariance of the state (P) as follows:

x += K y
P -= K H P

I would like to update 'x' and 'P' without computing the matrix inverse S^{-1}.

In the following reference, a method is given "for calculating (H P H^t + R)^{-1} H in the conventional Kalman filter without explicitly computing an inverse." (using U D U^T, or LDL^t)  Of course, (H P H^t + R)^{-1} is equal to S^{-1}, but this confuses me because "S^{-1} H" does not appear in the computation of K....and so, it is not clear to me, how the value of S^{-1}H can be used to compute K.

'Kalman Filtering; Theory and Practice Using MATLAB', second edition, by Grewal and Andrews
(click the second link)

Intersection between polynomial curve and parametric line

30 May 2013 - 12:42 PM

I have a polynomial curve defined by a set of coefficients (a_0, a_1, a_2, ... a_N ):


y(x) = a_0 + a_1*x + a_2*x^2 + ... a_N*x^N

I also have a parametric line:


p(t) = a + b*t

I wish to find the value of "t" such that the parametric line intersects with the polynomial curve.

Clearly, the first step is to expand the parametric equation:

p_x(t) = a_x + b_x*t
p_y(t) = a_y + b_y*t

Plugging in, I get this nasty thing:

a_y + b_y*t = a_0 + a_1*(a_x + b_x*t) + a_2*(a_x+b_x*t)^2 + a_3*(a_x+b_x*t)^3 + ...

I have no idea how to solve this for "t".

I want a numerical solution that works for arbitrary N, so I'm not expecting to find a closed form solution...I'm fine using any linear algebra or minimization techniques to get the answer, I'm just not sure what the most effective method would be.

Edit: I'm thinking that perhaps the proper approach is via "curve implicization" to convert the polynomial curve into a parametric form, thereby making it easier to compute the intersection.  I found this paper and I think it may be possible to implicitize this polynomial curve by using Sylvester's matrix elimination method as briefly described here ( http://www.cs.cmu.edu/~hulya/Publications/IJCV03Paper.pdf , p107 )...but I'm still a bit confounded.

Avoiding address already in use

25 August 2012 - 04:45 PM

I wrote my server in C++ and put it on am amazon ec2-micro instance, listening for connections on port 1234. Tested it over period of weeks with no issues. I left it running indefinitely for several months and after some period of time (unknown) discovered it was no longer running. I logged in and tried to restart and got the "address already in use" error when attempting to bind the listensocket to port 1234. Note that SO_REUSEADDR was already set. Over a period of several days I continued to try and it has never been released. I suppose this amazon instance is set with TIME_WAIT=infinity so it will wait until server reboots, but I am afraid to reboot it due to posts like this: http://blog.9minutes...ot-t1micro-ec2/

I have discovered that whenever I kill the server process when it is currently connected to a client, this error will occur when I try to restart the server..so I need to change the port that it waits on to get it back up. But thats not viable solution, because clients need to hardcode the port to connect to. What do I do?

bool resume_listening()
   std::cout << "Listening for new connections..\n";
   if ( ::listen( listenSocket, SOMAXCONN ) == SOCKET_ERROR )
	perror("listen listenSocket");
	std::cout << "Error listening on socket\n";
	return false;
   return true;
  bool create_listen_socket(int port)
   std::cout << "Creating listener socket..\n";
   //create listen socket
   listenSocket = socket( AF_INET, SOCK_STREAM, 0 );
   if (listenSocket == INVALID_SOCKET) {
	perror("create listenSocket");
	std::cout << "Unable to create listenSocket\n";
	return false;
   // The sockaddr_in structure specifies the address family,
   // IP address, and port of the client to be connected to.
   struct sockaddr_in service;
   service.sin_family = AF_INET;
   service.sin_addr.s_addr = INADDR_ANY;
   service.sin_port = htons(port);
   // Enable address reuse
   //discussion: http://hea-www.harvard.edu/~fine/Tech/addrinuse.html
   int on = 1;
   setsockopt( listenSocket, SOL_SOCKET, SO_REUSEADDR, (const char*)&on, sizeof(on) );
   if ( bind(listenSocket, (SOCKADDR*)&service, sizeof(service) ) == SOCKET_ERROR )
	perror("bind listenSocket");
	std::cout << "Unable to bind listenSocket\n";
	return false;
   return resume_listening();

Geometry triangle problem

10 March 2012 - 07:24 PM

Imagine a camera orbiting an spherical object. For a given orbit rotation, I'm trying to find out what the maximum change in the observed image angle of any point on the surface of the spherical object would be. I've reduced the problem to the diagram shown below.

The object is centered at A. B is the original camera location and D is the rotated camera location after orbiting. C is the point on the surface of the object. The original observed angle is ABC = atan( r/d). However, I can't figure out how to calculate Theta2 = angle ADC.