Question about coordinate problem at zero
-
Hi!
I have a question that is not directly about SketchUp or Ruby but still a problem...
I need coordinate values that are positive so I use abs(x) to get it from negative coordinates and that works fine.
The problem I have is that when the coordinates are precisely at 0, (x==0 || y==0 || z==0) the rest of the math doesn't work.
My experiments with it havent worked so far.
For example I've tried with setting it to a very small value if the coordinate is exactly 0.
I'm unsure what to Google for to find any info.Does anyone know how these things are usually solved?
(Sorry for beeing a bit cryptic and a bit off topic.)
-
aspect ratio of some objects won't center on [0,0,0] with snap
usealy two coordinate ok one not
try turning off snapit still dosn't work
you might need more precision.
make sure you object is a group
it gives 2x precision
but don't expode complety if your group object smaller .001, it will disapear from view
hit undo if it doses.here a plugin that will shape a object to a better precision
scaleGroupFloat_dj Ver 1.6.5
Copyright Feb 15, 2013
DukeJazz: by James Cochran
http://sketchucation.com/forums/viewtopic.php?f=323&t=45254Info: Best high precision 3d scale and move tool yet.
add zoro to numbers of lenght
1.0000001 -
Hej.
Isent abs kind of slow ?
I used it before for something for the same reason as you, but got very slow code.
A hack would be to round of to around 0,001 or something. Might avoid floating point precision errors as well.
Edit: Sorry did not read you post thourougly.
@unknownuser said:
For example I've tried with setting it to a very small value if the coordinate is exactly 0.
-
Difficult to say what to do without knowing what the purpose of the code is. Sounds like 0 is an edge case for you - if you cannot make the calculation work with 0, then maybe you need to make a special processing case for when you're values are 0.
-
Thanks for your replies.
This isnt directly connected to SU and is from a C++ project of mine.
However I solved it.
Turned out I needed a custom fmod function since the one built into C really is a remainder function and not a modulo function.
Advertisement