- Home /
How do I scale a vector from another vector?
I'm trying to manipulate a mass cloud of vectors and the one thing that has left me stumped is how do I scale them from a center vector?
My code thus far can scale the mass from world center, but I want to be able to see the mass scale from my 3D cursor that I define.
So, basically, this is the section of code that loops through all the points. Looks fairly simple, but I can't seem to think of how to change the scale origin.
point.position=point.position*(1+(Input.GetAxis("Mouse Y"))/200);
Any help would be appreciated.
Answer by sparkzbarca · Mar 11, 2013 at 12:21 PM
should be something like
vectorToScale.transform.position = vectorToScale.position - centerVector.position * ScaleValue;
that assumes uniform scaling. you could also do non uniform(scaling on one axis more than another) by multiplying by a vector instead of a float.
that will basically take however far the vectors are away from the center object and move them a set distance further away. which is basically scaling for the purposes of dealing with one vector to another.
Is that what you want?
Thanks! Your math was wrong, but it led me to find out what I was really supposed to do. All your code did was translate the vector mass. So, to both translate and scale, this is the code that did the trick:
point.position=point.position-(point.position-Crossair)*0.001;
I have no idea how I figured this out, except from just experimenting with the code, so as long as it works, I'm happy. :D
ack that would be bad math my order of operations would have skewed it
it should have been (vectorpos - centerpos) * scale
not vector - center * scale
Your answer
Follow this Question
Related Questions
How do I convert a normal to a scale? 2 Answers
change the length of the vector 1 Answer
Are Real Vector Fonts Possible in Unity? 3 Answers
Tree creator and terrain editor 0 Answers