Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Rush3fan · Mar 11, 2013 at 10:18 AM · scalevector

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

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?

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Rush3fan · Mar 11, 2013 at 07:27 PM 0
Share

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

avatar image sparkzbarca · Mar 12, 2013 at 12:03 AM 0
Share

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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I convert a normal to a scale? 2 Answers

I have a GUI element that highlights an onscreen object with a circle. This circle needs to scale according to the object's distance from the camera in order to compensate for perspective, but the thickness of the circle needs to stay the same. 0 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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges