Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
This question was closed Jul 02, 2018 at 02:11 PM by Bunny83 for the following reason:

The question is answered, right answer was accepted

avatar image
6
Question by RoR · Mar 17, 2011 at 06:25 PM · vector3programmingnormalize

Vector normalization question

When normalized, a vector keeps the same direction but its length is 1.0.

Can someone explain to me what normalization does and how/why it's used? A vector is a point. But it has direction and a length ?

Comment
Comments Locked
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

6 Replies

  • Sort: 
avatar image
12
Best Answer

Answer by Eric5h5 · Mar 17, 2011 at 06:52 PM

A vector is either a point, or a direction. See the Ray struct, for example. It's two Vector3s, and the first Vector3 is the origin and the second Vector3 is the direction. If it's a direction, then it has a length. Vector3(0, 0, 5) is a direction of 5 units along the z axis, so it has a length of 5. If you normalize that, it's Vector3(0, 0, 1). You would do this when you only want the direction and don't care about the length.

Comment
Comments Locked · 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 RoR · Mar 17, 2011 at 08:49 PM 0
Share

After normaliIng and getting V3(0,0,1) which tells us that it is in the z axis direction. That let's us know which axis it's direction but what if the direction isn't on an axis and perhaps at a 45 degree angle. Rather than having it be on the axis. How would you show diagonal? V3(0,1,1)?

avatar image Eric5h5 · Mar 17, 2011 at 09:53 PM 1
Share

Yes, (0, 1, 1) is 45 diagonal, though the length is greater than 1. If you normalized it, it would be approximately (0, .707, .707).

avatar image
14

Answer by biebuster · Oct 04, 2015 at 12:41 PM

Alright let's say that we want to find the normalized version of (2, 4, 0)

First just to clear up any confussion: the magnitude (or length!) is:

 //The square root of: x * x + y * y + z * z

Now when we normalize something, that magnitude needs to be 1. Alright now for the actual explanation.

So first of all let's find out how we find the direction. imagine we have a vector called: 0, 4, 0. you have this cordinate system here: http://i.imgur.com/pUp8SX3.png So bassicly we're taking our vector and comparing it to the absoloute 0, 0, 0, place of our coordinate. And in our case, compared to our vector of 0, 4, 0 the direction only goes upwards. That's why the direction then ends up being 0, 1, 0

0, 4, 0 direction = 0, 1, 0;

Now if it was 0, 2, 0, this would happen: http://imgur.com/GPhlI4w

Aright let's take a vector that has these values: 4, 4, 0; if we had a vector with 4, 4, 0 then this would happen: http://i.imgur.com/BX1CCNR.png

In this case you'd be able to have any values at x, and y, AND if those values were excatly the same it would give: 1, 1, 0

4, 4, 0 direction = 1, 1, 0

finally let's take our 2, 4, 0 vector. http://i.imgur.com/xNM4JNG.png

2, 4, 0 direction = 1, 2, 0;

But what does this have to do with normalization? well let's take the 3 direction vectors we had before:

4, 4, 0 direction = 1, 1, 0;

0, 4, 0 direction = 0, 1, 0;

2, 4, 0 direction = 1, 2, 0;

When we want the normalization we want the magnitude of these values. So let's find the magnitude here:

 //1, 1, 0 magnitude = square root of: 1 * 1 + 1 * 1 = 1.41;
 //0, 1, 0 magnitude = square root of: 1 * 1 =            1;
 //1, 2, 0 magnitude = square root of: 1 * 1 + 2 * 2 = 2.23;

0, 1, 0 doesn't need to be normalized cause it's magnitude is 1! perfect!

1, 1, 0 however needs to be normalized. And sadly the only way to do this is just let a computer divide it by what makes it go down to 1. Not something we would easily be able to calculate. Same goes for 1, 2, 0

And that is that! I know this comment is from 2011, but this answer was mostly made to help people like me who really strucled with it, even after reading these other answers, and the unity documentation. or it's just 1 hour of my life wasted have a good day

Comment
Comments Locked · Show 4 · 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 Ronnie-Grahn · Apr 29, 2017 at 09:18 AM 0
Share

Thank you for this explanation! Well done!

avatar image mdm5382 · May 18, 2017 at 01:46 AM 0
Share

It helped me thanks

avatar image Dolzen · Feb 10, 2018 at 05:31 AM 0
Share

you answer helped me a lot thanks

avatar image d1xt1r · Jul 02, 2018 at 06:36 AM 0
Share

Thank you!

avatar image
5

Answer by flaviusxvii · Mar 17, 2011 at 06:29 PM

A vector exists in a vector space, which has an origin. So every "point" is a line from the origin to that point.

The vector [1, 1, 1] is a line from [0, 0, 0] to [1, 1, 1].

Normalizing a vector preserves the direction, but moves the point to exactly one unit from the origin.

Comment
Comments Locked · Show 1 · 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 DJ-Antony · Apr 02, 2018 at 10:27 PM 0
Share

Top Lad. $$anonymous$$uch appreciated for explaining it in plain english. Now i get it we're only moving the object 1 vector unit across between two points or 1 unit of magnitude across...

avatar image
2

Answer by Owen-Reynolds · Mar 18, 2011 at 04:22 PM

A use for normalize:

// bullet is speed 5, aimed at timmy:
float3 v = ((timmy.transform.position - transform.position).Normalized)*5;
bullet.velocity = v;

The Normalized converts the gap between timmy and myself to length 1, and the *5 gives the bullet a speed of 5.

bullet.LookAt("timmy"); bullet.rigidbody.velocity = bullet.forward*5; is the more common way (in Unity) of doing it. Normalized is often used for the oddball "I have the right direction, but it's the wrong length" problems, or when you can't use LookAt.

Comment
Comments Locked · 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
0

Answer by sparkzbarca · Mar 04, 2013 at 03:36 AM

a normalized vector is the slope of the line on which the vector lies (of course this is only useful if the vector represents a line more commonly referred to as a direction)

knowing the slope of a line is useful a lot so it's a common operation.

Comment
Comments Locked · 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
  • 1
  • 2
  • ›

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

Multiple Cars not working 1 Answer

What is the difference between Normalize & Normalized 1 Answer

Vector2 Normalize ? 3 Answers

Vector3.Normalize not working for particular input? 2 Answers

Problem with normal snapping and rotations. 1 Answer


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