x


Normalized Coordinates are Exponentially inccorect

So I have been trying to narrow out some errors in mouse track with where you click and the normalized coordinates produced. EG, the left is 0 right is 1, center is 0.9. It exponentially decreases the amount it changes. Ive made my own normalization function, but I would also like to know what i am doing wrong I hate that I'm reinventing the wheel.

more ▼

asked Jul 20 '11 at 07:32 PM

captaincheerios gravatar image

captaincheerios
16 6 7 10

And where's the code? Or should we start guessing? Also i don't quite get what you really want. Do you want "normal" normalized coordinates (0..1 linear) or do you want them to be some kind of exponential?

Jul 20 '11 at 07:52 PM Bunny83

Right. Center would be .5 unless doing something non-linear, like exponential. Some code would be real helpful.

Jul 20 '11 at 08:11 PM DaveA
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

In general: normalizing is almost always the same procedure. Just divide the value by the maximum-range. If the x-coordinate goes from 0 to Screen.width just divide by Screen.width...

more ▼

answered Jul 20 '11 at 07:54 PM

Bunny83 gravatar image

Bunny83
46.8k 12 50 210

(comments are locked)
10|3000 characters needed characters left

Its a property within the Input.mousePosition class so really this is the code to show me the information. Debug.Log(Input.mousePosition.normalized.ToString()); You can try Input.mosuePosition.Normalize(); however Input.mousePosition.normalized produces the same results if you use that method. I already made my own Normalized coordinate its not hard. However the unity function built into the mousePosition class is wrong. EG the reason for this post wondering if anyone else used the Unity Method to do this instead of writing their own.

more ▼

answered Jul 20 '11 at 08:14 PM

captaincheerios gravatar image

captaincheerios
16 6 7 10

Kindly notice that mousePosition is a VECTOR3!!!!!!!!!!!!.. just normalizing it will probably not behave the way you think.

Jul 20 '11 at 08:34 PM flaviusxvii

Exactly, Normalize or notmalized will normalize the Vector3 or Vector2 to the length of 1.0 It will be always 1.0 just the direction is preserved. But that takes all 3 axis into account.
http://en.wikipedia.org/wiki/Normalized_vector

normalized will just divide each component by the length of the vector so the length becomes 1.0f

2D example: Vector2(5,7) the length of this vector is sqrt(5² + 7²) = 8.6023...
The normalized vector is (0.5812..., 0,8137...). The length of this vector is 1.0 so it's a normalized vector, but you want to normalize a single value. That's something different.

To get the normalized mouseposition you have to normalize each component seperately. x coord divided by Screen.width and y coord divided by Screen.height.

Jul 20 '11 at 09:38 PM Bunny83

Ohh, and don't post comments as answers. There's a comment button for that. Answers should answer the question.

http://answers.unity3d.com/page/faq.html

Jul 20 '11 at 09:39 PM Bunny83
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1001
x529
x40
x2
x1

asked: Jul 20 '11 at 07:32 PM

Seen: 1327 times

Last Updated: Jul 20 '11 at 09:39 PM