yahastu

Members
  • Content count

    657
  • Joined

  • Last visited

Community Reputation

154 Neutral

About yahastu

  • Rank
    Advanced Member
  1. Got it working.  The trick was modifying the list of semicolon delimitted items manually rather than via clicking on it and using the built-in path list editor.
  2. I tried adding the paths to "Configuration Properties => C/C++ => General => Additional Include directories" and "Configuration Properties => Linker => General => Additional Library directories" (in addition to the Microsoft.Cpp.Win32.user properties), and also changed the include files to specify the full-path location to the D3DX headers as in your example, but there is no change. Perhaps the problem lies with the fact that I cannot use an absolute path to specify the library name -- eg, in "#pragma comment (lib, "d3d11.lib")" and so, it may continue to look for the library in the Windows 7 sdk first.... It seems like this would be a problem for all Windows 7 users that attempt to use DirectX...there must be a common resolution
  3. 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?
  4. Kalman filter predict/update equations are here: https://en.wikipedia.org/wiki/Kalman_filter   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. Reference: 'Kalman Filtering; Theory and Practice Using MATLAB', second edition, by Grewal and Andrews http://books.google.com/books?id=sZbxLK-NKb0C&q=+without+explicitly+inverting#v=snippet&q=without%20explicitly%20inverting&f=false (click the second link)
  5. Thanks for your reply Alvaro.  If I can rearrange the nasty equation into a polynomial in t, then yes I can easily find the roots of it.  The difficulty is in automatically calculating the coefficients of this polynomial, given that it is a summation of terms such as "a_N*(a_x+b_x*t)^N" which would effect the coefficients for ALL terms less than N. I think that implicitizing the equation might just come down to constructing an appropriate matrix and taking the determinant, after which point I'd have two parametric equations with two unknown parameters, should should be solvable...so I'm not sure which approach is actually easier
  6. 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.
  7. 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: [url="http://blog.9minutesnooze.com/reboot-t1micro-ec2/"]http://blog.9minutes...ot-t1micro-ec2/[/url] 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? [CODE] 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"; closesocket(listenSocket); 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) ); //setup if ( bind(listenSocket, (SOCKADDR*)&service, sizeof(service) ) == SOCKET_ERROR ) { perror("bind listenSocket"); std::cout << "Unable to bind listenSocket\n"; closesocket(listenSocket); return false; } return resume_listening(); } [/CODE]
  8. Geometry triangle problem

    Thanks both of you. jjd, your approach of converting into vectors is a good method to keep in mind for the future as well! I was hoping to rearrange the solution in order to be able to compute the necessary value of Theta1 in order to achieve a given value of Theta2. However that is not possible via these solution methods. Do you think there is a closed form solution for the reverse problem?
  9. Geometry triangle problem

    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.
  10. Intersecting two angular ranges

    [quote name='pantaloons' timestamp='1319250619' post='4875238'] Quite right -- it's a rather fiddly problem although my general view is an arithmetic moduli solution will be cleaner in the end than any hull type solution (see below). I'll try one more time, if I were writing this for work etc I may just write a brute force test for all integer 4-tuples to ensure it is probably correct and easily debug failing cases, hopefully you get the idea of how the solution *might* be constructed.[/quote] This one works, gives the same output as my method on my unit tests but is obviously cleaner. Thanks for your help
  11. Intersecting two angular ranges

    For the original problem, your solution doesn't work as-is. Consider the intersection of (0,90) with (358, 70)... Using your method, min1=0, min2 = 358, max1 = 90, max2 = 70 --> 430 Then min3 = max(min1,min2) = max(0,358) = 358 and max3 = min(max1,max2) = min(90,430) = 90 In this case both those numbers are wrong, it gave the union rather than intersection For the point in range problem, your solution works
  12. Suppose that an "angular range" is specified by a starting and ending angle, proceeding clockwise. The first angular range is (a,b) and the second is (c,d). If both angular ranges span more than 180 degrees then it is possible that there are two intersection ranges. However if they do not EACH span more than 180 degrees, then the intersection can be represented as a single angular range denoted by (e,f). What is it? In all cases, it is clear that e = a or c, and f = b or d. A few examples to begin with: intersection of (a=45, b=10) with (c=350, d=30) is (e=350, f=10) intersection of (a=45, b=10) with (c=270, d=300) is (e=270, f=300) intersection of (a=45, b=95) with (c=55, d=80) is (e=55, f=80) Progress: -------- After much mucking about looking for a simple analytical solution that doesn't seem to exist, I realized that if you sort all four angles (a,b,c,d) radially, then find the index "i" such that the angle between "i" and "i-1" (using modular indices) does not belong to either of the input angular ranges, then the intersection should be given by angles at indices "i+1" and "i+2". Finding this index requires checking whether an angle belongs within a given angular range, and that requires a more mathematical definition of the set of angles in an angular range. My first thought was that an angular range could be defined by the cross product. That is, the range (a,b) could be written as the set { p \in (0,2pi) | cross(vec(a),vec(p)) > 0 && cross(vec(p), vec(b)) > 0 } where vec(a) is the 2D cartesian vector represented by the angle 'a', and cross is the 2D analog of the cross product (ie, the z-component of the 3D cross product). However, then I realized that this definition only works for angular ranges spanning less than 180 degrees. I'm having difficulty coming up with a simple mathematical definition that can be used to test whether a point is inside of an arbitrary angular range which might span more than 180 degrees. Also, if anyone can think of a simpler overall approach, I'd be happy to hear it.
  13. I have searched but haven't been able to find any actual code examples showing how to use slimdx on a control within a windows form. I created a simple panel control and passed the handle to slimdx. Then I tried to adapt the slimdx tutorial code for triangle rendering onto the control by doing the following: a) put all the global variables needed for rendering onto the main winform class b) put all the setup code inside the winform constructor after InitializeComponent c) made a destructor for the winform and put all the directx cleanup code there d) made a RenderFrame() function and hooked it up with MessagePump.Run(this, RenderFrame) in the end of the winform constructor. Problems I'm having: 1) The triangle is not visible, although the back buffer is cleared to the clear color 2) When the application exits, it throws some crash exception 3) If I click the minimize button on the winform, the computer immediately freezes and must be re manually rebooted [code] using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Security.Cryptography; using SlimDX; using SlimDX.D3DCompiler; using SlimDX.Direct3D11; using SlimDX.DXGI; using SlimDX.Windows; using Device = SlimDX.Direct3D11.Device; using Resource = SlimDX.Direct3D11.Resource; namespace MyNamespace { public partial class frmMain : Form { Device device; SwapChain swapChain; DeviceContext context; Viewport viewport; RenderTargetView renderTarget; ShaderSignature inputSignature; VertexShader vertexShader; PixelShader pixelShader; DataStream vertices; SlimDX.Direct3D11.Buffer vertexBuffer; InputLayout layout; public frmMain() { InitializeComponent(); //this should make slimdx render onto "gPanel" control var description = new SwapChainDescription() { BufferCount = 1, Usage = Usage.RenderTargetOutput, OutputHandle = gPanel.Handle, IsWindowed = true, ModeDescription = new ModeDescription(0, 0, new Rational(60, 1), Format.R8G8B8A8_UNorm), SampleDescription = new SampleDescription(1, 0), Flags = SwapChainFlags.AllowModeSwitch, SwapEffect = SwapEffect.Discard }; Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, description, out device, out swapChain); // create a view of our render target, which is the backbuffer of the swap chain we just created using (var resource = Resource.FromSwapChain<Texture2D>(swapChain, 0)) renderTarget = new RenderTargetView(device, resource); // prevent DXGI handling of alt+enter, which doesn't work properly with Winforms using (var factory = swapChain.GetParent<Factory>()) factory.SetWindowAssociation(gPanel.Handle, WindowAssociationFlags.IgnoreAltEnter); // setting a viewport is required if you want to actually see anything context = device.ImmediateContext; viewport = new Viewport(0.0f, 0.0f, gPanel.ClientSize.Width, gPanel.ClientSize.Height); context.OutputMerger.SetTargets(renderTarget); context.Rasterizer.SetViewports(viewport); // load and compile the vertex shader using (var bytecode = ShaderBytecode.CompileFromFile("triangle.fx", "VShader", "vs_4_0", ShaderFlags.None, EffectFlags.None)) { inputSignature = ShaderSignature.GetInputSignature(bytecode); vertexShader = new VertexShader(device, bytecode); } // load and compile the pixel shader using (var bytecode = ShaderBytecode.CompileFromFile("triangle.fx", "PShader", "ps_4_0", ShaderFlags.None, EffectFlags.None)) pixelShader = new PixelShader(device, bytecode); // create test vertex data, making sure to rewind the stream afterward vertices = new DataStream(12 * 3, true, true); vertices.Write(new Vector3(0.0f, 0.5f, 0.5f)); vertices.Write(new Vector3(0.5f, -0.5f, 0.5f)); vertices.Write(new Vector3(-0.5f, -0.5f, 0.5f)); vertices.Position = 0; // create the vertex layout and buffer var elements = new[] { new InputElement("POSITION", 0, Format.R32G32B32_Float, 0) }; layout = new InputLayout(device, inputSignature, elements); vertexBuffer = new SlimDX.Direct3D11.Buffer(device, vertices, 12 * 3, ResourceUsage.Default, BindFlags.VertexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0); // configure the Input Assembler portion of the pipeline with the vertex data context.InputAssembler.InputLayout = layout; context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; context.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertexBuffer, 12, 0)); // set the shaders context.VertexShader.Set(vertexShader); context.PixelShader.Set(pixelShader); MessagePump.Run(this, RenderFrame); } ~frmMain() { // clean up all resources // anything we missed will show up in the debug output vertices.Close(); vertexBuffer.Dispose(); layout.Dispose(); inputSignature.Dispose(); vertexShader.Dispose(); pixelShader.Dispose(); renderTarget.Dispose(); swapChain.Dispose(); device.Dispose(); } private void RenderFrame() { // clear the render target to a soothing blue context.ClearRenderTargetView(renderTarget, new Color4(0.5f, 0.5f, 1.0f)); context.Draw(3, 0); swapChain.Present(0, PresentFlags.None); } } [/code]
  14. What is this function?

    [quote name='japro' timestamp='1313656012' post='4850652'] f_k(x) = 0.5*(x^k + 1 - (1-x)^(1/k)) maybe? [/quote] Nice! Modified to fit the coordinate system I described, f_k(x) = 1 - 0.5*((1-x)^k + 1 - x^(1/k)) It's not perfectly symmetric, but close enough for me!
  15. What is this function?

    [quote name='Brother Bob' timestamp='1313620353' post='4850508'] So my functions bent the curve to the wrong corner according to your picture, but that's just a matter of inverting them. Looks like you want the power function japro and I suggested, and you adjust k depending on how much you want the function to approach the corners. If k approaches 0, it is bent towars the upper left corner in your graph, and if it approaches infinity it is bent towards the lower right corner. [/quote] Sorry, I guess I'm not explaining myself clearly enough. When I said "pulled from the midpoint towards (0,1)" I meant that the curves should be symmetric about the line X-1 for all parametric values. The circle equation you gave is just a single function, it does not describe a parametric family of curves that includes the line f(x)=x. I can think of a way to do this but it uses a Bezier spline segment, with vertices at (0,0) and (0,1), and then define a parametric path for the control points. ie, the parametric value could slide a reference point along the line X-1, and then the control points could be defined by the vector from this reference point to the starting vertex, with the length of this vector being a hard-coded value. I just feel like there has to be a simpler way to define this family of curves.[attachment=4967:funcs2.jpg]