[BACK]Return to spline.dem CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gnuplot / demo

Annotation of OpenXM_contrib/gnuplot/demo/spline.dem, Revision 1.1

1.1     ! maekawa     1: #
        !             2: # $Id: spline.dem,v 1.3 1997/04/05 19:44:48 drd Exp $
        !             3: #
        !             4: # Some curve plotting using common cubic polynomial basis function for cagd.
        !             5: #
        !             6: #                              Gershon Elber, Aug. 1992
        !             7: #
        !             8: set xrang [0:1]
        !             9: set grid
        !            10:
        !            11: set yrange[-0.2:1.4]
        !            12: m0(x) = 1
        !            13: m1(x) = x
        !            14: m2(x) = x**2
        !            15: m3(x) = x**3
        !            16: set title "The cubic Monomial basis functions"
        !            17: plot m0(x), m1(x), m2(x), m3(x)
        !            18: pause -1 "Press return to continue"
        !            19:
        !            20: h00(x) = x**2 * ( 2 * x - 3) + 1
        !            21: h01(x) = -x**2 * (2 * x - 3)
        !            22: h10(x) = x * (x - 1)**2
        !            23: h11(x) = x**2 * (x - 1)
        !            24:
        !            25: set title "The cubic Hermite basis functions"
        !            26: plot h00(x), h01(x), h10(x), h11(x)
        !            27: pause -1 "Press return to continue"
        !            28:
        !            29: bez0(x) = (1 - x)**3
        !            30: bez1(x) = 3 * (1 - x)**2 * x
        !            31: bez2(x) = 3 * (1 - x) * x**2
        !            32: bez3(x) = x**3
        !            33: set title "The cubic Bezier basis functions"
        !            34: plot bez0(x), bez1(x), bez2(x), bez3(x)
        !            35: pause -1 "Press return to continue"
        !            36:
        !            37: bsp0(x) = ( 1 - 3 * x + 3 * x**2 - x**3 ) / 6;
        !            38: bsp1(x) = ( 4 - 6 * x**2 + 3 * x**3 ) / 6;
        !            39: bsp2(x) = ( 1 + 3 * x + 3 * x**2 - 3 * x**3 ) / 6
        !            40: bsp3(x) = x**3 / 6
        !            41: set title "The cubic uniform Bspline basis functions"
        !            42: plot bsp0(x), bsp1(x), bsp2(x), bsp3(x)
        !            43: pause -1 "Press return to continue"
        !            44:
        !            45: y0 = 1
        !            46: y1 = 0.2
        !            47: y2 = 0.8
        !            48: y3 = 0
        !            49:
        !            50: x0 = 0
        !            51: x1 = 0.33
        !            52: x2 = 0.66
        !            53: x3 = 1
        !            54:
        !            55: xv0 = -0.3
        !            56: yv0 = 0.5
        !            57: xv1 = -0.4
        !            58: yv1 = 0.2
        !            59:
        !            60: set arrow from x0,y0 to x1,y1 nohead
        !            61: set arrow from x1,y1 to x2,y2 nohead
        !            62: set arrow from x2,y2 to x3,y3 nohead
        !            63:
        !            64: cub_bezier_x(t) = bez0(t) * x0 + bez1(t) * x1 + bez2(t) * x2 + bez3(t) * x3
        !            65: cub_bezier_y(t) = bez0(t) * y0 + bez1(t) * y1 + bez2(t) * y2 + bez3(t) * y3
        !            66: cub_bsplin_x(t) = bsp0(t) * x0 + bsp1(t) * x1 + bsp2(t) * x2 + bsp3(t) * x3
        !            67: cub_bsplin_y(t) = bsp0(t) * y0 + bsp1(t) * y1 + bsp2(t) * y2 + bsp3(t) * y3
        !            68:
        !            69: set parametric
        !            70: set trange [0:1]
        !            71: set title "The cubic Bezier/Bspline basis functions in use"
        !            72: plot cub_bezier_x(t), cub_bezier_y(t) with lines 2,\
        !            73:      cub_bsplin_x(t), cub_bsplin_y(t) with lines 3
        !            74: pause -1 "Press return to continue"
        !            75:
        !            76: set noarrow
        !            77: #
        !            78: # Note the arrows here, scaled by 1/3 so they will fit into plotting area
        !            79: #
        !            80: set arrow from x1,y1 to x1+xv0/3,y1+yv0/3
        !            81: set arrow from x2,y2 to x2+xv1/3,y2+yv1/3
        !            82: set arrow from x1,y1 to x1+xv0,y1+yv0
        !            83: set arrow from x2,y2 to x2+xv1,y2+yv1
        !            84:
        !            85: cub_hermit_x1(t) = h00(t) * x1 + h01(t) * x2 + h10(t) * xv0 + h11(t) * xv1
        !            86: cub_hermit_y1(t) = h00(t) * y1 + h01(t) * y2 + h10(t) * yv0 + h11(t) * yv1
        !            87: cub_hermit_x2(t) = h00(t) * x1 + h01(t) * x2 + h10(t) * xv0*3 + h11(t) * xv1*3
        !            88: cub_hermit_y2(t) = h00(t) * y1 + h01(t) * y2 + h10(t) * yv0*3 + h11(t) * yv1*3
        !            89: set title "The cubic Hermite basis functions in use"
        !            90: plot cub_hermit_x1(t), cub_hermit_y1(t) with lines 2,\
        !            91:      cub_hermit_x2(t), cub_hermit_y2(t) with lines 3
        !            92: pause -1 "Press return to continue"
        !            93:
        !            94: set noparametric
        !            95: set noarrow
        !            96: set auto
        !            97: set nogrid
        !            98: set title ""

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>