SteveNi Posted September 24, 2016 Share Posted September 24, 2016 Hi I have an object and I want to move it lets say 1.5 units in a certain direction ( so move it along a certain vector ), so I tried what you can see in the picture. Of course this doesn't work, because 1.5*{1,1,1} will result in moving the obj of 1.5 units in every axis. So how can I work out the correct numbers to move the obj by a certain amount in a certain direction? Quote Link to comment Share on other sites More sharing options...
berglte Posted September 24, 2016 Share Posted September 24, 2016 You need to normalize your direction vector first before the multiplication. vector dir = {1, 1, 1}; v@P += 1.5 * normalize(dir); 1 Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted September 24, 2016 Share Posted September 24, 2016 float distance = chf("distance"); vector direction = chv("direction"); @P += normalize(direction) * distance; Quote Link to comment Share on other sites More sharing options...
SteveNi Posted September 24, 2016 Author Share Posted September 24, 2016 Quote You need to normalize your direction vector first before the multiplication. Ok Thanks it works! As far as I knew normalizing something would have made it equal to 1, could you explain better what it does? Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted September 24, 2016 Share Posted September 24, 2016 after normalizing the vector (dividing each component by its length) it is exactly one unit long. Quote Link to comment Share on other sites More sharing options...
SteveNi Posted September 24, 2016 Author Share Posted September 24, 2016 Ok thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.