opengl - Orders of Modifying the Shape -


i started learning transformations in opengl, , confused steps of modifying shape different position, angles or sizes.

for example, have house in 2d scene follow: enter image description here

let's want transforms scene in (a) scene in part (b) of house, how should decide whether should scale it, translate or rotate first ? outcome going different ?

thank you.

the outcome going different based on order of transforms.

here pseudocode answers question directly (assuming each function takes x,y,z parameters):

translate(-6, 0, 0) rotate(0, 0, 135) scale(2, 1, 1) 

now let's @ why order matters!

first, have without transforms: no transforms

next, let's see happens when rotate counter-clockwise 45° , translate along positive x axis:

rotate translate

notice how translation caused square move toward top-right corner? because rotation transform modifies local axes. positive x points top-right. if rotated 180° +x point towards left instead of right.

now let's @ happens when perform same transforms in reverse order:

translate rotate

this time translation moved square right expected. after square rotated.

check out open.gl page on transformations more detail, around math behind of this.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -