Can't Divide @numpt by @ptnum?
4539
4
0
Sept. 23, 2019 11:44 a.m.
Windows 10
Houdini 17.5.360
This should give me a ratio, but instead results in 0 for all my points. Same in VOPs. Why is that? Does it error out when trying to divide by zero?
I can use a fit function as seen below as a temporary workaround…
Thanks,
Luke
Edited by Luke Letellier - Sept. 23, 2019 11:53:14
Attachments:
Letellier_PtRatio_Debug.hiplc (139.2 KB)
Andr
Member
900 posts
Joined: Feb. 2016
Offline
Sept. 23, 2019 12:56 p.m.
hi, probably you need to convert them to float values before the operation
Sept. 23, 2019 1:03 p.m.
Yes like Andr says, you are dividing two integers and the result is a fraction. Since integers have no fractional part the result is truncated to 0. (If i remember correctly the dotted line in VOPs denotes an implicit type cast)
BabaJ
Member
2038 posts
Joined: Sept. 2015
Online
Sept. 23, 2019 9:04 p.m.
…and you only need to have one value as a float:
f@ratio = (@ptnum*1.0)/@numpt; f@ratio = @ptnum/(@numpt*1.0); f@ratio = @ptnum/float(@numpt); f@ratio = float(@ptnum)/@numpt;
Edited by BabaJ - Sept. 24, 2019 10:18:21
tamte
Member
8539 posts
Joined: July 2007
Online
Sept. 23, 2019 9:45 p.m.
most of the times however you want something like this
f@ratio = @ptnum /(@numpt - 1.0 );
to get values in full range from 0 to 1
Tomas Slancik FX Supervisor Method Studios, NY