[RFC PATCH] Make fake profile average depth come out right

Anton Lundin glance at acc.umu.se
Sun Nov 3 22:47:01 UTC 2013


On 03 November, 2013 - Linus Torvalds wrote:

> On Sun, Nov 3, 2013 at 2:44 PM, Anton Lundin <glance at acc.umu.se> wrote:
> >> +/*
> >> + * Good fake dive profiles are hard.
> >> + *
> >> + * "depthtime" is the integral of the dive depth over
> >> + * time ("area" of the dive profile). We want that
> >> + * area to match the average depth (avg_d*max_t).
> >> + *
> >> + * To do that, we generate a 6-point profile:
> >> + *
> >> + *  (0, 0)
> >> + *  (t0, max_d)
> >> + *  (t1, max_d)
> >> + *  (t2, d)
> >> + *  (t3, d)
> >> + *  (max_t, 0)
> >
> > Hmm.. These ones should be t1 to t4, not t0 to t3?
> 
> Yes.
> 
> >> + * That six-point profile gives a total area of:
> >> + *
> >> + *   (max_d*max_t) - (max_d*t1) - (max_d-d)*(t4-t3)
> >
> > Why do you care about the max_d*t1 part? Isn't that just the accent
> > slope? There should be more factors there if we should care about all
> > the accent slopes in that formula.
> 
> Heh. Draw it out. Yes, you can make the formula much more complex like
> yours is, but by selecting the shapes right, you get the much simpler
> one.
> 
> The max_t*t1 is twice the area of the triangle generated by the
> descent, yes. But because the ascent has the same shape, you can
> actually find the *same* triangle on the ascent path. And then the
> only remaining shape to subtract from the "big rectangle" is the time
> we spend at depth "d" (which is a rectangle of size
> "(t4-t3)*(max_d*d)").
> 

Ah. It was the tricky part about using the same accent and decent speed
that i didn't get.

Then everything makes sense again.

But i still thinks that your formula is missing a (max_d-d)*(max_t-t4)
factor. Its not a big one, but its still one.

//Anton


> > Shouldn't the whole thing look something more like:
> > (max_d*max_t) - (max_d*t1*0.5) - (max_d-d)*(t3-t2)*0.5
> > - (max_d-d)*(t4-t3) - d*(max_t-t4)*0.5 - (max_d-d)*(max_t-t4)
> 
> Simplify it. You should get to the exact same answer. In particular,
> the same slope part:
> 
> >> + * And the "same ascent/descent rates" requirement
> >> + * gives us (time per depth must be same):
> >> + *
> >> + *   t1 / max_d = (t3-t2) / (max_d-d)
> >> + *   t1 / max_d = (max_t-t4) / d
> 
> can be used to simplify your complex expression to my simple one.
> Except I didn't do it that way, it's easier to do by just partitioning
> the shape to begin with and noticing that the (two) triangles that
> happen at ascent (first from d_max to d, and then from d to 0) fit
> with the triangle at descent.
> 
> > The rest looks sane based on those assumptions, but i can't really
> > figure out why you care about the (max_d*t1) part.
> 
> Your equation had it too, look at it. You just had the first obvious
> triangle (the "(max_d*t1*0.5)" in your equation), it's just that your
> other terms end up adding up to another triangle, and the sum of those
> is my "max_d*t1".
> 
> And no, I didn't actually do the simplification, and I didn't check
> that your more complex expression is correct.. But I'm pretty sure my
> simpler one *is* correct, though.
> 
>                 Linus

-- 
Anton Lundin	+46702-161604


More information about the subsurface mailing list