Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Kepakiano

Member Since 27 Oct 2012
Offline Last Active Mar 09 2013 06:14 AM

#5026054 Generate random perpendicular unit vector

Posted by Kepakiano on 27 January 2013 - 08:17 AM

This is what I would do:
http://pastebin.com/fr4aU0cw (needs C++11)

1. Generate a random unit vector
2. Make it orthogonal to your given vector by using the Gram-Schmidt Process (http://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process)

Edit: The snippet does not check, whether v and random u are linearly independent.


PARTNERS