I'm currently developing a 3D game engine in C# using OpenTK.  I have basic game objects, and each game object has transform (translation, rotation and scaling). A game object can have components (much like Unity).  One game object (The camera game object) has three components, A camera, free move and a free look component. The free move component allows the user to move the camera around the scene, whilst the free look camera is SUPPOSED to rotate the camera. However, I get this odd effect:    (Note that, the plane isn't changing position, it seems the camera is ... turning upside down?)  On top of that, once I rotate the camera, moving the camera (using the arrow keys) gets really weird, up can become down, left can become right. It's all very odd.  Anywho, here is the update method for my Free Look component:  protected override void OnUpdate(object sender, UpdateEventArgs e) {     Rectangle bounds = Game.GetCurrentGame().Window.Bounds;      Vector2 center = new Vector2(bounds.Left + (bounds.Width / 2), bounds.Top + (bounds.Height / 2));      Vector2 mousePosition = new Vector2(System.Windows.Forms.Cursor.Position.X,                                             System.Windows.Forms.Cursor.Position.Y);     Vector2 deltaPosition = center - mousePosition;      bool rotX = deltaPosition.X != 0;     bool rotY = deltaPosition.Y != 0;      if(rotY)         Transform.Rotate(new Vector3(0, 1, 0), MathHelper.DegreesToRadians(-deltaPosition.X * sensitivity));     if(rotX)         Transform.Rotate(new Vector3(1, 0, 0), MathHelper.DegreesToRadians(-deltaPosition.Y * sensitivity));      if (rotY || rotX)         System.Windows.Forms.Cursor.Position = new Point((int)center.X, (int)center.Y);      base.OnUpdate(sender, e); }   here is the Rotate method in my transform class:  public void Rotate(Vector3 axis, float angle) {     rotation = (Quaternion.FromAxisAngle(axis, angle) * rotation).Normalized(); }   I hope someone can help me get to the bottom of this, I've been so frustrated!  If there's any other code you need to see, just let me know.
I see questions come up quite often that have this underlying issue, but they're all caught up in the particulars of a given feature or tool. Here's an attempt to create a canonical answer we can refer users to when this comes up - with lots of animated examples! :)    Let's say we're making a first-person camera. The basic idea is it should yaw to look left &amp; right, and pitch to look up &amp; down. So we write a bit of code like this (using Unity as an example):  void Update() {     float speed = lookSpeed * Time.deltaTime;      // Yaw around the y axis using the player's horizontal input.             transform.Rotate(0f, Input.GetAxis("Horizontal") * speed, 0f);      // Pitch around the x axis using the player's vertical input.     transform.Rotate(-Input.GetAxis("Vertical") * speed,  0f, 0f); }   or maybe  // Construct a quaternion or a matrix representing incremental camera rotation. Quaternion rotation = Quaternion.Euler(                         -Input.GetAxis("Vertical") * speed,                          Input.GetAxis("Horizontal") * speed,                          0);  // Fold this change into the camera's current rotation. transform.rotation *= rotation;   And it mostly works, but over time the view starts to get crooked. The camera seems to be turning on its roll axis (z) even though we only told it to rotate on the x and y!    This can also happen if we're trying to manipulate an object in front of the camera - say it's a globe we want to turn to look around:    The same problem - after a while the North pole starts to wander away to the left or right. We're giving input on two axes but we're getting this confusing rotation on a third. And it happens whether we apply all our rotations around the object's local axes or the world's global axes.  In many engines you'll also see this in the inspector - rotate the object in the world, and suddenly numbers change on an axis we didn't even touch!    So, is this an engine bug? How do we tell the program we don't want it adding extra rotation?  Does it have something to do with Euler angles? Should I use Quaternions or Rotation Matrices or Basis Vectors instead?
How to change the numbering of \part, \chapter, \section, ... to alphabetical, Roman numbers, etc Yesterday, my laptop caught a virus which caused massive damage. Since them, I have been trying to recover important files before reformatting my computer, a task the virus has not made easy.   Restoration points predating the attack have been deleted.  Most of my folders show empty.  My Start menu is essentially empty, with the exception of Trillian and Mirror's Edge. The same goes for my Desktop, which only has programs which were installed after the attack.  Searching for files through my computer is pretty much useless, as it only rarely brings up anything. I suspect most of my files have not been deleted. While my folders show empty, uTorrent still does display them and I can open them from here. Unfortunately, when I select Open Containing Folder, the folder still shows as completely empty even if I'm currently watching a video from that very folder. Further adding evidence to the not-deleted-just-missing theory, the data recovery software I'm using (Restoration) cannot find only find an handful of the missing files.   If they were deleted, I could do a forensic recovery to get them back but since they're probably still somewhere on my computer, just out out of my reach, I can't find them.   Under those circumstances, is there a way I can recover those files? Keyboard shortcut to focus on (idle) terminal I would like to know, if there is possible to use keyboard shortcut to focus on first idle (non working) terminal window in unity (13.10)? Something like Ctr+Alt+T, but before opening the new instance of terminal, searching for any idle instance? Error: Declaration of MyClass::start_lvl() should be compatible with that of Walker_Nav_Menu::start_lvl() My table doesn't fit; what are my options? I have a table that I want to insert on a page, but at least one (perhaps both) of the following conditions are met:   The table is too wide to fit within the text block or page. That is, I'm exceeding some horizontal restriction. The table is too tall to fit within the text block or page. That is, I'm exceeding some vertical restriction.   What are my options to make this table fit? If it doesn't fit, regardless of my attempts, what other options exist? Preloading images with jQuery I'm looking for a quick and easy way to preload images with JavaScript. I'm using jQuery if that's important.  I saw this here ():  function complexLoad(config, fileNames) {   for (var x = 0; x &lt; fileNames.length; x++) {     $("&lt;img&gt;").attr({       id: fileNames[x],       src: config.imgDir + fileNames[x] + config.imgFormat,       title: "The " + fileNames[x] + " nebula"     }).appendTo("#" + config.imgContainer).css({ display: "none" });   } };   But, it looks a bit over-the-top for what I want!  I know there are jQuery plugins out there that do this but they all seem a bit big (in size); I just need a quick, easy and short way of preloading images! What are tag badges? How do they work? What's the "official" explanation for Harry's (and everyone else's) absence from muggle school? So a bunch of kids all of a sudden "go missing" from school.  Harry Potter having attended school for a couple of years before starting at Hogwarts, one semester just doesn't show up.  How is this solved? What do parents say when a school teacher calls and wonders where their pupil is?  I assume that Hogwarts isn't an officially recognized school (though perhaps it is?), and due to education being compulsory, someone would do the math and find that low-hundreds of kids go missing in the transition from primary to secondary school every year. 30" monitor has black border around desktop I have been using a 24" monitor with my macbook pro early 2011 connected via a mini display port to DVI adaptor.  I recently received an HP Z30i 30" monitor.  When I connect to it with an mini display port to display port adaptor, although it displays at the monitors native 2560x1600 resolution, the mac is scaling the desktop display down so as to leave a 1cm or so black border around the desktop.  The mac reports using a resolution of 2560x1600 and the display reports this also.   This makes the display blurry as single pixels become sub pixels.   The display looks like the same effect as having "under scan" turned on when using an HDMI cable at 1080p.  I thought that maybe there was a hardware or display problem, but when I boot off a previous system partition from a different hard-drive using the same OS (10.8.5) release, the monitor set up works perfectly.  This proves the OS release, display and the hardware, so I'm thinking that there must be a preferences problem with my current setup.  Perhaps the under scan setting is somehow being applied to this display when it's not using HDMI?  I've tried deleting /Library/Preferences/com.apple.windowserver.plist, ~/Library/Preferences/ByHost/com.apple.windowserver.HostNumber.plist and rebooting but no results.   The scaling is applied before the login screen and logging in as a different user has the same problem.  Any ideas?  It's driving me nuts, I've got this nice 30" screen and I can't use it! Render issue - Model doesn't appear to be on any layers and won't render Really odd on this... using Blender 2.75... I started modelling and lost the objects from the 3d view, but they were still showing in the object lists on the outlier... I was able to copy them and continued working... when I did a test render I discovered that only the original lost objects were rendering and nothing that I had modelled over the previous 2/3hrs was showing up...  I have no idea what I did but I created another 3d view and the original bits showed up along with the layer buttons which had been missing from the screen which I thought was just a new feature from  2.75...!  Picture to show the 2 screens, top one doesn't render but bottom one does    Any idea's what I've done? Execute command from file in current shell I want to executed command from file (which is script) in current shell in terminal.  Example: I have file ch_dir contains following:  #!/bin/bash cd /usr   Now if I execute file usually as following then it executes commands in different shell:  pandya@pandya-desktop:~$ ./ch_dir pandya@pandya-desktop:~$   Here cd /user is executed in different shell.  But I want to execute in Current shell. How do I do that?  Note: Here cd is only used to explain. Question's aim is to execute any command in current shell It turns out that removing a virtual package with apt-get only remove the package itself,  leaving behind the real packages that were installed by it  So how do you remove a virtual package, along with all the real packages that it installs? What would happen if the earth would stop spinning? How much heavier would we be? I mean absolutely stop spinning. How much does the centrifugal force affect us?  If you give technical answers (please do), please explain them in laymen's terms, thanks.  Edit: I am asking what would be different if the earth were not spinning. Nevermind the part about it stopping. dimension of a subspace spanned by two subspaces If $M$ and $ N$ be the subspaces of a vector space $V$ then prove that  $(\dim M) + (\dim N) = (\dim M+N) + (\dim M \cap N)$. Let $p(x)$ be a polynomial of degree $n$ satisfying $p(x)\geq 0$ for all $x$. That is, for all $x$, $p(x) = a_n x^n + a_{n-1} x^{n-1} + \cdots + a_1 x + a_0 \geq 0$, $a_n\neq 0$.  Show that $p(x)+p&#39;(x)+p&#39;&#39;(x)+\cdots+p^{(n)}(x)\geq 0$ for all $x$ where $p^{(i)}(x)$ is the $i^\text{th}$  derivative.  My interest: I know that, we can rewrite the LDE as follows  $$ p(x)+p&#39;(x)+p&#39;&#39;(x)+\cdots+p^{(n)}(x) = Lp(x) $$  where $L := I + D + D^2  + \cdots + D^{(n)}$. Can we say anything about a linear operator of this kind so that it does not change the sign of the input it takes? I can try to solve the question by writing for all the derivatives and factoring them using $p(x)$, but I think there should be a clever way of showing this by the properties of $L$. Can I figure out a solution by just looking at $L$ and the sign of $p(x)$ as in the question? Where should I look for that? Name of the book/series based on magicians who tap into computer grid? How do I "un-roll" the viewport? MySQL Date Between setSystemUiVisibility(SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) does not work What is covered by CDIC savings deposit insurance? In the unlikely event that a financial institution fails in Canada, what is covered by the Canadian Deposit Insurance Corporation?  What is the limit of coverage?