Jump to content

strange offset with custom active attribute


valorSix

Recommended Posts

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

Link to comment
Share on other sites

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 by Noobini
Link to comment
Share on other sites

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 by Noobini
Link to comment
Share on other sites

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 by Noobini
Link to comment
Share on other sites

@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

Link to comment
Share on other sites

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 by Noobini
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...