03.08.2013 Views

S.N.A.K.E.: A Dynamically Reconfigurable Artificial Sensate Skin ...

S.N.A.K.E.: A Dynamically Reconfigurable Artificial Sensate Skin ...

S.N.A.K.E.: A Dynamically Reconfigurable Artificial Sensate Skin ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

9<br />

c:\Documents and Settings\Gerardo\My ...)\Thesis\Code\Example1\OpenGLControl.cpp<br />

527 vector_t a, b;<br />

528<br />

529 // calculate the vectors A and B<br />

530 // note that v[3] is defined with counterclockwise winding in mind<br />

531 // a<br />

532 a.x = v[0].x - v[1].x;<br />

533 a.y = v[0].y - v[1].y;<br />

534 a.z = v[0].z - v[1].z;<br />

535 // b<br />

536 b.x = v[1].x - v[2].x;<br />

537 b.y = v[1].y - v[2].y;<br />

538 b.z = v[1].z - v[2].z;<br />

539<br />

540 // calculate the cross product and place the resulting vector<br />

541 // into the address specified by vector_t *normal<br />

542 normal->x = (a.y * b.z) - (a.z * b.y);<br />

543 normal->y = (a.z * b.x) - (a.x * b.z);<br />

544 normal->z = (a.x * b.y) - (a.y * b.x);<br />

545<br />

546 // normalize<br />

547 normalize(normal);<br />

548 }<br />

549

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!