diff --git a/lib/+artoa/+soundsources/calculateDrift.m b/lib/+artoa/+soundsources/calculateDrift.m new file mode 100644 index 0000000000000000000000000000000000000000..bf2e80664a1341bcb0f393f7fb506d61f1545f50 --- /dev/null +++ b/lib/+artoa/+soundsources/calculateDrift.m @@ -0,0 +1,23 @@ +function [drift] = calculateDrift(pStartRafosDate, pEndRafosDate, pStartOffset, pEndOffset) +%CALCULATEDRIFT Calculates the drift corresponding to 1 day. +% Calculates the drift of a soundsource in 1 day in seconds. +% +% Parameters: +% pStartRafosDate (double): The start rafos date that should be +% taken into account. +% pEndRafosDate (double): The end rafos date. +% pStartOffset (double): The starting offset [s]. +% pEndOffset (double): The end offset [s]. +% +% Returns: +% drift (double): The calculated drift [s/day]. + +%% Calculate drift +duration = pEndRafosDate - pStartRafosDate; +totalOffset = pEndOffset - pStartOffset; + +drift = totalOffset / duration; + + +end + diff --git a/lib/+artoa/+soundsources/calculateToaAtTimestep.m b/lib/+artoa/+soundsources/calculateToaAtTimestep.m new file mode 100644 index 0000000000000000000000000000000000000000..ad87af4f2cbdb541b41c8d443faf3dc642974d40 --- /dev/null +++ b/lib/+artoa/+soundsources/calculateToaAtTimestep.m @@ -0,0 +1,16 @@ +function [toa] = calculateToaAtTimestep(pToa, pTimestep, pStartOffset, pDrift) +%CALCULATETOAATTIMESTEP Calculates the TOA at the given timestep. +% Calculates the new TOA at the given timestep. +% +% Parameters: +% pToa (double): The start TOA. +% pTimestep (double): The timestep from start of the soundsource +% in rafos days. +% pStartOffset (double): The start offset of the soundsource. +% pDrift (double): The drift of the soundsource in seconds per day. + +%% Calculate new toa +toa = pToa + pStartOffset + pDrift * pTimestep; + +end +