JacquesLucke / animation_nodes

Node based visual scripting system designed for motion graphics in Blender.
Other
2.29k stars 342 forks source link

mathutils precision issues and bool, round, debug, sockets etc #327

Closed og76 closed 8 years ago

og76 commented 9 years ago

This is not a An issue per se. But implications lead to several issues or non functional AN things. We need to deal with these somehow.

Core issue: mathutils.Vector and alike are converting (even rounded) values to floats so:

generally, precision is spoiled by the float representation if u use mathutils Vec etc.

Specific issues / use cases so far

Note that it does work inside nodes etc where functions/operations accept tuples or other triplets, but there too, mathutils spoils the bool if used (so don't use it, feed plain tuples if bool..)

Solutions?

round data node example blend and img from it precision1 precision2

ps bumped first into this and more with bvh tree and others, but that is another (sad) story. :)

JacquesLucke commented 9 years ago

I implemented rounding in the debug node because otherwise you get these weird numbers everywhere and in most cases you don't care wether a number is 1.2 or 1.20000000001

Comparison between floats is always difficult. Most of the time you just check if the distance between two values or vectors is smaller than a specific epsilon.

og76 commented 9 years ago

ok

JacquesLucke commented 9 years ago

Hm I think rounding a vector doesn't make that much sense. And the Problem with comparison can appear after that as well. Changing he Compare node to have a Special behavior when comparing vectors and floats is possible but not suuuper nice from the coding point of view. Also, when do you really need a vector comparison? I never needed it.

og76 commented 9 years ago

first time I needed it was when doin object inside/outside mesh tests the bvh nearest or mesh closes point are very unreliable up to a point, cause they consider only polygons etc (long story..) so I extended them with sort of is on edge/is on vert variants for that I was comparing vectors. eventually I have fallen to vectors distance, but first I tried to make a node setup involving bool

another area is the geometry part, where sometimes you need to see if the point is on line or in plane etc. there also I'm trying to avoid this ..

they are marginal cases and with some doc we can skip implementing that

however, I see an issue if boolean compare supports vectors and the result is wrong, even if only in comparison to some debug

Note that rounding floats is ok! only vector/euler/quat arrays of floats are wrong when after rounding if u use mathutils... of them

og76 commented 9 years ago

or maybe boolean should not support vector euler quat and matrix ...

JacquesLucke commented 8 years ago

compare Well, a real comparison seems to work but in cases you described I think you should always use proximity or so. I don't think we should drop the support for comparing vectors etc...

This is a problem everyone who does something like you did has to deal with eventually. I don't see how we can solve this fundamental issue in a nice way.