News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Bezier Spline - want to expand <sub> and <sup>

Started by dedndave, May 29, 2013, 08:08:07 PM

Previous topic - Next topic

johnsa

Ahh.. got you. So you need a curve that passes through the points but takes min(n) and max(n) and makes sure that those are basically the peak/dip of the curve and only other parts of the curve may extend past the data-point.

dedndave

yah - the math used doesn't account for that
i am looking into it - it is not as simple as i thought it should be - lol

FORTRANS

Hi,

   Linear interpolation will not overshoot.  Higher order interpolation
pretty much has to overshoot unless your data is rather constrained
to begin with.  Clamping of some sort will be needed.  Or weird
constraints on the control points (which kinda obviate the use of the
higher order).

Regards,

Steve N.

daydreamer

what about take cosine as interpolation?
cosine outputs between 1.0 and -1.0 so its easy to scale up and you only use first half of curve so lenght is pi
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

dedndave

good thinking - something along that line

i was thinking of identifying the minima and maxima, then doing the curve in sections   :P
i just have to figure out how to get the endpoints of each section to have 0 slope

there's probably a much more efficient way
i have to look at the math in the original post

daydreamer

Quote from: dedndave on June 05, 2013, 03:41:51 AM
good thinking - something along that line

i was thinking of identifying the minima and maxima, then doing the curve in sections   :P
i just have to figure out how to get the endpoints of each section to have 0 slope

there's probably a much more efficient way
i have to look at the math in the original post
why dont try loop thru SSE MAXSS AND MINSS instruction
and save result of where you are in the curve everytime maximum gets bigger than previous max and minimum gets smaller than previous min



my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

FORTRANS

Quote from: dedndave on June 05, 2013, 03:41:51 AM
i just have to figure out how to get the endpoints of each section to have 0 slope

Hi,

   Well, as you are using Bezier curves, all you need to do is have the
line from the last control point to the last data point have a slope of
zero.  So, after all the calculations, when you determine that you are
at the end of a section, set the control point's Y value to equal the Y
value of the data point.  That sounds a bit crude, but it will get you
a zero slope.

Cheers,

Steve N.

dedndave

yah - a minima or maxima can be found by comparing each Y value with the adjacent Y values'

i tried that method, Steve - it didn't work the way i think it should have - lol
i am going to take another look at it - my code may have missed something

FORTRANS

Hi Dave,

Quote from: dedndave on June 05, 2013, 07:09:10 AM
i tried that method, Steve - it didn't work the way i think it should have - lol

   I just looked at some curves in my draw program.  And they
seemed to work okay(ish).  Do you have the values for the four
points?

Quote
i am going to take another look at it - my code may have missed something

   Okay, good luck.

Regards,

Steve N.

dedndave

i have the routine cleaned up
i added support for 2-point lines
and it validates the knot quantity parameter
i did not add the SSE divide that qWord suggested
reason is - if you are using the SSE registers for something else - this routine only uses FPU registers
next week, when i have more time, i will take qWord's advice and try an SSE version   :P

i also added some "knobs" to play with...
FILE_RANDOM   EQU 1          ;non-zero for file data points, zero for random data points
DATA_POINTS   EQU 0          ;non-zero to draw data points
CONTROL_LINES EQU 0          ;non-zero to draw control lines
FLAT_MINMAX   EQU 0          ;non-zero to flatten minima/maxima control lines

TIMER_ELAPSE  EQU 60         ;interval time in mS


the biggest change there is, i added some "real-world" file data   :biggrin:
you can look at Input.jpg to see what the same data looks like in image form

dedndave


Siekmanski

Very nice overview.  :t
But where's the 3D representation?  :biggrin:
Creative coders use backward thinking techniques as a strategy.

dedndave

lol
that is down the road a bit
had to get the basics running, first

i want to use file mapping to access the data
that will require a lot of work
not that file mapping is that hard - but a lot of the current code will have to be updated

jj2007

Dave, stay away from the patients with +348 mmHg, they are dangerous. Those in the blue area are on Ducky's table, I suppose?

dedndave

well - the program autoranges the pressures
that way, all the colors are used, no matter what the pressure range

however, it's funny you mention that
earlier versions limited the pressure to -20 and +250 mmHg
i did that because i was concerned about rejecting bad data packets

the doctor had a patient that was exceeding +250, so he couldn't see all the data
the limits are now set to -999.9 and +999.9 mmHg   :P

when you start out, the pressures are at 0 and +1
so, a "Ducky" patient would be solid dark blue, i think - lol
kinda like a BSOD, but without the white text   :biggrin: