Math interpolation example

Simple example to make looped interpolation between two points.

Compilation

Easiest way to get this example running is to go to examples directory in package root, and run:

$ ./build.sh math_intp

build.sh script compiles Ano script to C, copies source files in place and pops up instructions what to do next. Follow them. Check also examples/README for more info.

Preview

; ------------------------------------------------------------------------------
; math_intp.ano
;
; To compile:
;
; $ ./build/ano ./examples/math_intp/math_intp.ano > \
;     engine/dsl_ano.h
; ------------------------------------------------------------------------------
;
@ANO_SCRIPT_NAME		math_intp
@ANO_SCRIPT_VERSION		0.0.1
@ANO_SCRIPT_DESCRIPTION	Simple interpolation example
;
@ANO_FLAGS_USE_PROTOS		[ ]
@ANO_FLAGS_VAR_NAME_SUBS	[ ]
@ANO_FLAGS_VAR_WARN_UNUSED	[ ]
;
; Copyright © 2016-2026, Jani Salonen <salojan@goto10.co>
; All rights reserved.
;
; Example to make looped interpolation between two points.
;

main [exit: 0] {
	; Set initial points for interpolation.
	;
	mov	_p1 (& -1.1, 0.0, 0.0)
	mov	_p2 (& -1.1, -0.75, 0.0)
	mov	_p3 (& 1.9, 0.75, 0.0)
	mov	_p4 (& 1.9, 0.0, 0.0)

	; Set interpolation point, bias and tension.
	;
	mov	_intp (0.0)
	mov	_bias (0.0)
	mov	_tension (0.0)

	; Loop for ten interpolation points.
	;
	print "Interpolated point is (x, y):\n\n"

	loop (mov i ([int] 0); i < 10; inc i) {
		coords_intp_hermite_x (_p1, _p2, _p3, _p4, \
			_intp, _bias, _tension)

		print	" " . rc . ""

		coords_intp_hermite_y (_p1, _p2, _p3, _p4, \
			_intp, _bias, _tension)

		print	rc . "\n"

		add	_intp (0.1)
	}

	print "\n"
}
; ------------------------------------------------------------------------------
; math_intp.w2c
;
; To compile:
;
; $ ./build/widget ./examples/math_intp/math_intp.w2c > \
;     engine/widget_defs.h
; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------
; math_intp.m2c
;
; To compile:
;
; $ ./build/menu ./examples/math_intp/math_intp.m2c > \
;     engine/menu_defs.h
; ------------------------------------------------------------------------------

Copyright © 2026, Jani Salonen <salojan at goto10 piste co>. Piste is finnish word and means dot. All rights reserved.