Basic Vector Math question. I am confused.

Discussions about Coding and Scripting
Post Reply
MrLoathsome
Inhuman
Posts: 958
Joined: Wed Mar 31, 2010 9:02 pm
Personal rank: I am quite rank.
Location: MrLoathsome fell out of the world!

Basic Vector Math question. I am confused.

Post by MrLoathsome »

Ran across something that seemed odd the other day.
More than likely I need to read more about vectors and am just missing something obvious.

Was trying to use a constant that is declared in Engine.Pawn:

Code: Select all

var	const 	vector	Floor;			// Normal of floor pawn is standing on (only used
									//	by PHYS_Spider)
Being curious, I decided to log the values it was getting while my pawn was using PHYS_Spider.
Added 2 log lines at the start and end of a function that was changing Rotation in some state code:

Code: Select all

log(self@"FlipR Entry"@newRot@Physics);
log(self@"FlipR Exit"@newRot@Physics@Floor);
Now look at some of the output:

Code: Select all

ScriptLog: DM-Stalwart.Tent5 FlipR Entry 0,0,32768 1
ScriptLog: DM-Stalwart.Tent5 FlipR Exit 0,0,32768 1 0.000000,0.000000,0.000000
ScriptLog: DM-Stalwart.Tent9 FlipR Entry 7421,1998,0 10
ScriptLog: DM-Stalwart.Tent9 FlipR Exit 7421,1998,0 10 -0.000000,-0.000000,1.000000
ScriptLog: DM-Stalwart.Tent9 FlipR Entry 7780,798,0 10
ScriptLog: DM-Stalwart.Tent9 FlipR Exit 7780,798,0 10 -0.000000,-0.000000,1.000000
ScriptLog: DM-Stalwart.Tent9 FlipR Entry 769,64626,0 10
ScriptLog: DM-Stalwart.Tent9 FlipR Exit 769,64626,0 10 -0.242536,-0.000000,0.970142
Note Tent5 is using PHYS_Walking (1) and Tent9 is using PHYS_Spider (10)

WTF is -0.0000000 doing in there? :ironic: :loool:
Did I miss a day of math class?
Is this part of "Common Core"? :ironic2:
blarg
MrLoathsome
Inhuman
Posts: 958
Joined: Wed Mar 31, 2010 9:02 pm
Personal rank: I am quite rank.
Location: MrLoathsome fell out of the world!

Re: Basic Vector Math question. I am confused.

Post by MrLoathsome »

Bump !!! :highfive:

Did some more searching, and found this interesting info:

http://www.johndcook.com/blog/2010/06/1 ... gned-zero/

Is that what is going on with the Floor constant?

I stuck this line of code into something just to see what the output would be:

Code: Select all

	if ((0.0 == -0.0) && (+0.0 == 0.0) && (0.0 == 0.0))
		log("Zero == Zero");
It dumps "Zero == Zero" into the log every time.

Do I have to convert the Floor value to a string and then parse it to make use of the -0.0 or +0.0 values?

Speaking of Zero. That Floor constant is referenced/used a grand total of Zero times in any of the default UT source code near
as I could find. Perhaps this is why.

It does change when PHYS_Spider is being used, so it must be doing something..... I just gotta figure out exactly what.

Has this been looked into before?

I am now less confused than I was an hour ago, but have more questions..... :roll:
blarg
User avatar
Barbie
Godlike
Posts: 2808
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Basic Vector Math question. I am confused.

Post by Barbie »

Have you checked the Wikipedia article?
Just a guess: the sign in that special case above may help to detect the orientation of an Actor (head up or head turned around).
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
MrLoathsome
Inhuman
Posts: 958
Joined: Wed Mar 31, 2010 9:02 pm
Personal rank: I am quite rank.
Location: MrLoathsome fell out of the world!

Re: Basic Vector Math question. I am confused.

Post by MrLoathsome »

I had not checked that, but it matches the info in that link I found.
I learned something today. Learning is fun. :|

Am now even less confused, but have more to think about...... :?: :?: :idea: :idea!: :cry:

Pretty sure your guess there is correct. I just gotta run some tests on the info
that the Floor constant is supplying, and then write a function that makes use of it.
blarg
User avatar
Wormbo
Adept
Posts: 258
Joined: Sat Aug 24, 2013 6:04 pm
Contact:

Re: Basic Vector Math question. I am confused.

Post by Wormbo »

-0.000000 Doesn't actually have to be negative zero. The string representation of float values may only contain six digits after the decimal point, but the value range for the float type allows many values between -0.000001 and 0.000001 that would be rounded to 0 and -0, respectively. You might simply be seeing rounding errors there that caused the Z component of Floor to be a tiny bit below 1.0 and thus the other two components can't both be exactly zero anymore.
Higor
Godlike
Posts: 1866
Joined: Sun Mar 04, 2012 6:47 pm

Re: Basic Vector Math question. I am confused.

Post by Higor »

It's just how vectors and coordinates are transformed between FRotator and FVector.
You'd figure out what i'm talking about if you looked at UnMath.h in UT's public headers.
Post Reply