3D Theory - Collisions - from Forum

Delete By: TGA (the_great_apple) - 2008-04-03 12:22
Hi, 
 
From: https://www.euclideanspace.com/threed/games/examples/cars/collisions/index.htm 
 
"To rotate the vector through 90 degrees we just swap the x and y coordinates." This is untrue: 
 
(x, y) = (1, 1) 
(y, x) = (1, 1) 
 
Clearly not rotated 90 degrees. Swapping the x and y coordinates mirrors in the x-y plane, and so will seem to swap the coordinates if they lie on either axis. 
 
By 90 degrees are actually obtained by premultiplying the vector by the matrix: 
 
[0, 1 
-1, 0] 
 
for anti-clockwise rotations and: 
 
[0, -1 
1, 0] 
 
for clockwise rotations. 
 
In the article it doesn't matter if you rotate clockwise or anti-clockwise, so you could just say you swap the x and y coordinates, and make one negative. So: 
 
(x, y) = (1, 1) 
(-y, x) = (-1, 1) # 90 degrees clockwise 
(y, -x) = (1, -1) # 90 degrees anti-clockwise 
 
The example spreadsheet is also wrong with the same error. 

metadata block
see also:
Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

cover Game Programming for Teens.

other games programming books

Commercial Software Shop

Where I can, I have put links to Amazon for commercial software, not directly related to this site, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.

cover Dark Basic Professional Edition - It is better to get this professional edition

cover This is a version of basic designed for building games, for example to rotate a cube you might do the following:
make object cube 1,100
for x=1 to 360
rotate object 1,x,x,0
next x

cover Game Programming with Darkbasic - book for above software

other commercial software

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2017 Martin John Baker - All rights reserved - privacy policy.