valorSix Posted October 8, 2020 Share Posted October 8, 2020 Hello, Some of my vex code is returning very strange values than what I thought it should be doing. I have this: i@startframe = floor(fit01(rand(@id*23.4234), 1001, 1050)); // create random start frames float duration = 15; //duration f@active = fit(@Frame-@startframe, @startframe, @startframe+duration, 0,1); //create value between start frame + duration However, my @active value doesn't start between 1001- 1050 as I specified, it instead starts from frames 2001- 2100. WHy is this? Why is it offset 1000 frames ?? would appreciate any help . thank you active_value_problem.hipnc Quote Link to comment Share on other sites More sharing options...
Noobini Posted October 8, 2020 Share Posted October 8, 2020 (edited) shouldn't logic be like this? int duration = 15; //duration f@active = fit(@Frame-@startframe, 0, duration, 0,1); //create value between start frame + duration btw, "active" as a fraction instead of 1...I'm scratching my head...for what purpose ? Shouldn't it be either 0 or 1 ? You can't be 'slightly' pregnant can you? Edited October 8, 2020 by Noobini Quote Link to comment Share on other sites More sharing options...
Noobini Posted October 8, 2020 Share Posted October 8, 2020 (edited) my 'guess' of what you are trying to do is this: int duration = 15; //duration i@active = @startframe < @Frame && @Frame < @startframe + duration; //active for the duration so that they all start off as 0...then up to certain frames...predetermined by wrangle create_startframe..they switch on...and remain active for duration....(then naturally switch off) Edited October 8, 2020 by Noobini Quote Link to comment Share on other sites More sharing options...
valorSix Posted October 8, 2020 Author Share Posted October 8, 2020 @Noobini Thanks, your first logic fixed the issue , but i'm still confused to how my example ended up being offset 1000 frames ? In my case I needed some float values, not just 1 or 0 but thanks for the example. appreciate it. Quote Link to comment Share on other sites More sharing options...
Noobini Posted October 8, 2020 Share Posted October 8, 2020 (edited) 11 minutes ago, valorSix said: @Noobini Thanks, your first logic fixed the issue , but i'm still confused to how my example ended up being offset 1000 frames ? In my case I needed some float values, not just 1 or 0 but thanks for the example. appreciate it. well because you offsetted it. the fit will try to fit a value from min/max to new min/new max....so you set the min to @start_frame which say randomly 1025....so if Frame is 1001 say, 1001 - 1025 is negative...this will never fit into your range....until the Frame is 'big' enough..ie when it reached 2000, then 2000 - 1000 something would more likely to give you 1000 something...and hence fit in your range. Edited October 8, 2020 by Noobini Quote Link to comment Share on other sites More sharing options...
valorSix Posted October 8, 2020 Author Share Posted October 8, 2020 @Noobini Not sure i'm following... How do you figure it would only be big enough when it reached Frame 2000 in your example? If the Value that is being fit is a negative number and not within my range than it should return 0. Only when it reaches the range specified (@startframe- @startframe+duration), than I should get the proper fit values of 0-1 . Thanks Quote Link to comment Share on other sites More sharing options...
Noobini Posted October 8, 2020 Share Posted October 8, 2020 (edited) 1 hour ago, valorSix said: @Noobini Not sure i'm following... How do you figure it would only be big enough when it reached Frame 2000 in your example? If the Value that is being fit is a negative number and not within my range than it should return 0. Only when it reaches the range specified (@startframe- @startframe+duration), than I should get the proper fit values of 0-1 . Thanks well yeah...it is returning 0 correctly isn't ? so say at frame 1500, 1500 - 1021 = 479 min/max = 1021/1036 is 479 in the range 1021 - 1036 ? NO, so it returns 0 correctly...what are you complaining about ? so as you scrub between 1001 and 1500....it's always 0.............................until Frame is big enough.. ie. as said, YOU introduced the offset from the correct range of 0 - duration as per my fix. right now, it may be difficult for you to visually see the effect of your offset error because you're using @startframe which is random. if you use a static offset like this, it's easier to observe the result float duration = 15; //duration f@active = fit(@Frame-@startframe, 300, 300+duration, 0,1); //create value between start frame + duration You'll see that it is offset by 300 frames And therefore you would see how my fix works as the offset is 0. Edited October 8, 2020 by Noobini Quote Link to comment Share on other sites More sharing options...
valorSix Posted October 9, 2020 Author Share Posted October 9, 2020 @Noobini I took a nap and when I woke up it made sense lol. I understand now. Thanks Noobini. 1 Quote Link to comment Share on other sites More sharing options...
Noobini Posted October 9, 2020 Share Posted October 9, 2020 4 hours ago, valorSix said: @Noobini I took a nap and when I woke up it made sense lol. I understand now. Thanks Noobini. yeah...beauty sleep does more than just improving your complexion. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.