You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I realised that the RoundingMethod.FLOOR doesn't actually work for the TimeType.EXACT.
To explain why it doesn't work, let's see an example:
Ex without any rounding/flooring
Timestamps
Frame 0: 0 ms
Frame 1: 33.333333 ms
Frame 2: 66.666666 ms
Frame 3: 100 ms
Frame 4: 133.333333 ms
Frame 5: 166.666666 ms
EXACT
Frame 0: [0, 33] ms
Frame 1: [34, 66] ms
Frame 2: [67, 99] ms
Frame 3: [100, 133] ms
Frame 4: [134, 166] ms
START
Frame 0: 0 ms
Frame 1: [1, 33] ms
Frame 2: [34, 66] ms
Frame 3: [67, 100] ms
Frame 4: [101, 133] ms
END
Frame 0: [1, 33] ms
Frame 1: [34, 66] ms
Frame 2: [67, 100] ms
Frame 3: [101, 133] ms
Ex with FLOOR
Timestamps
Frame 0: 0 ms
Frame 1: 33 ms
Frame 2: 66 ms
Frame 3: 100 ms
Frame 4: 133 ms
Frame 5: 166 ms
EXACT
Frame 0: [0, 32] ms
Frame 1: [33, 65] ms
Frame 2: [66, 99] ms
Frame 3: [100, 132] ms
Frame 4: [133, 165] ms
START
Frame 0: 0 ms
Frame 1: [1, 33] ms
Frame 2: [34, 66] ms
Frame 3: [67, 100] ms
Frame 4: [101, 133] ms
END
Frame 0: [1, 33] ms
Frame 1: [34, 66] ms
Frame 2: [67, 100] ms
Frame 3: [101, 133] ms
Remember, this is the interval for each type of timing:
EXACT: $[CurrentFrameTime, NextFrameTime[$
START: $]PreviousFrameTime , CurrentFrameTime]$
END: $]CurrentFrameTime, NextFrameTime]$
But, for our case, the interval are always integer, so it gives:
EXACT: $[\lceil CurrentFrameTime \rceil, \lceil NextFrameTime \rceil - 1]$
START: $[\lfloor PreviousFrameTime \rfloor + 1, \lfloor CurrentFrameTime \rfloor]$
END: $[\lfloor CurrentFrameTime \rfloor + 1, \lfloor NextFrameTime \rfloor]$
Currently, the program always output the timestamps in milliseconds, but actually, I would want to give the user a choice where he could select the precision from seconds to nanoseconds. I choosed a maximum of nanoseconds, because I highly doubt a user would need more precision than that.
Since I want the program to support maximum nanoseconds AND EXACT use ceil VS START/END use floor, it means that the timestamps would need to be stored with a precision just higher than nanoseconds $10^{-9}$ which means the timestamps would need to be stored with a unit of $10^{-10}$ and they would be floored.
With those change, def ms_to_frames(self, ms: int, time_type: TimeType) -> int would be replaced with def time_to_frame(self, time: int, input_precision: int, time_type: TimeType) -> int AND def frames_to_ms(self, frame: int, time_type: TimeType) -> int would be replaced with def frame_to_time(self, frame: int, output_precision: int, time_type: TimeType, middle_time: bool) -> int.
The text was updated successfully, but these errors were encountered:
I realised that the RoundingMethod.FLOOR doesn't actually work for the TimeType.EXACT.
To explain why it doesn't work, let's see an example:
Ex without any rounding/flooring
Timestamps
Frame 0: 0 ms
Frame 1: 33.333333 ms
Frame 2: 66.666666 ms
Frame 3: 100 ms
Frame 4: 133.333333 ms
Frame 5: 166.666666 ms
EXACT
Frame 0: [0, 33] ms
Frame 1: [34, 66] ms
Frame 2: [67, 99] ms
Frame 3: [100, 133] ms
Frame 4: [134, 166] ms
START
Frame 0: 0 ms
Frame 1: [1, 33] ms
Frame 2: [34, 66] ms
Frame 3: [67, 100] ms
Frame 4: [101, 133] ms
END
Frame 0: [1, 33] ms
Frame 1: [34, 66] ms
Frame 2: [67, 100] ms
Frame 3: [101, 133] ms
Ex with FLOOR
Timestamps
Frame 0: 0 ms
Frame 1: 33 ms
Frame 2: 66 ms
Frame 3: 100 ms
Frame 4: 133 ms
Frame 5: 166 ms
EXACT
Frame 0: [0, 32] ms
Frame 1: [33, 65] ms
Frame 2: [66, 99] ms
Frame 3: [100, 132] ms
Frame 4: [133, 165] ms
START
Frame 0: 0 ms
Frame 1: [1, 33] ms
Frame 2: [34, 66] ms
Frame 3: [67, 100] ms
Frame 4: [101, 133] ms
END
Frame 0: [1, 33] ms
Frame 1: [34, 66] ms
Frame 2: [67, 100] ms
Frame 3: [101, 133] ms
Remember, this is the interval for each type of timing:$[CurrentFrameTime, NextFrameTime[$ $]PreviousFrameTime , CurrentFrameTime]$ $]CurrentFrameTime, NextFrameTime]$
EXACT:
START:
END:
But, for our case, the interval are always integer, so it gives:$[\lceil CurrentFrameTime \rceil, \lceil NextFrameTime \rceil - 1]$ $[\lfloor PreviousFrameTime \rfloor + 1, \lfloor CurrentFrameTime \rfloor]$ $[\lfloor CurrentFrameTime \rfloor + 1, \lfloor NextFrameTime \rfloor]$
EXACT:
START:
END:
Currently, the program always output the timestamps in milliseconds, but actually, I would want to give the user a choice where he could select the precision from seconds to nanoseconds. I choosed a maximum of nanoseconds, because I highly doubt a user would need more precision than that.$10^{-9}$ which means the timestamps would need to be stored with a unit of $10^{-10}$ and they would be floored.
Since I want the program to support maximum nanoseconds AND EXACT use ceil VS START/END use floor, it means that the timestamps would need to be stored with a precision just higher than nanoseconds
With those change,
def ms_to_frames(self, ms: int, time_type: TimeType) -> int
would be replaced withdef time_to_frame(self, time: int, input_precision: int, time_type: TimeType) -> int
ANDdef frames_to_ms(self, frame: int, time_type: TimeType) -> int
would be replaced withdef frame_to_time(self, frame: int, output_precision: int, time_type: TimeType, middle_time: bool) -> int
.The text was updated successfully, but these errors were encountered: