Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Set vector orientation by another vector

Years of Service
User Offline
Joined: 27th Oct 2013
Posted: 14th Dec 2019 14:09
There is array of normalized vectors (points on sphere)

now i need to set their orientation by another vector ( for example objects normal ) which is also normalized (-1 to 1)

I read that first of all I need to create rotation matrix from normal and then rotate original vectors with it.
But how should i do this in DBPro?
DBPro Master
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 28th Dec 2019 18:19
I think I understand what you're trying to do. In the first pic, store the difference between the normalized sphere vectors and the normal of the plane. Then in the second pic when the plane's normal is shifted, adjust the sphere vectors by those stored offsets in regards to the plane's new normal. Don't overthink the problem, I think this can be solved with just simple vector subtraction/addition.

If you need to find the normal of the plane, make two segments that lie on it and take the cross product of them. Given the plane ABCD, take AB * AD and normalize the result.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Years of Service
User Offline
Joined: 23rd Jul 2006
Posted: 7th Jan 2020 17:51 Edited at: 7th Jan 2020 20:47

I wonder if you can just use NEWXVALUE() , NEWYVALUE() and NEWZVALUE() commands. This is assuming you just want to rotate the vectors by some angle that you know.
Enjoy your day.
Years of Service
User Offline
Joined: 27th Oct 2013
Posted: 17th Jan 2020 06:37
Yes, adding to vectors works fine.Like this:

Last thing I need is to add object's direction.I've orient my sphere to object normal,its works fine, but this object can be rotated so I have to add its direction too.
I try to add object direction to its normals and obviously it doesnt work

Login to post a reply

Server time is: 2020-08-05 14:29:39
Your offset time is: 2020-08-05 14:29:39