From: wayo.cavazos Date: Sun, 8 Oct 2006 12:03:07 +0000 (+0000) Subject: Nicer polygon-normal X-Git-Tag: 0.85~41 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=8b48c60ced4f251fa0329f7dfc3b7bbe2e36cc1e Nicer polygon-normal --- diff --git a/contrib/lindenmayer/lindenmayer.factor b/contrib/lindenmayer/lindenmayer.factor index 9acf45f611..8b800c9395 100644 --- a/contrib/lindenmayer/lindenmayer.factor +++ b/contrib/lindenmayer/lindenmayer.factor @@ -34,17 +34,7 @@ GL_LINES glBegin record-vertex step-turtle record-vertex glEnd ; ! (v0 - v1) x (v1 - v2) -: polygon-normal ( {_v0_v1_v2_} -- normal ) -0 over nth over 1 swap nth v- swap -1 over nth swap 2 swap nth v- cross ; - -! Test and replace with: -! -! : v0-v1 ( { v0 v1 v2 } -- vec ) first2 v- ; -! -! : v1-v2 ( { v0 v1 v2 } -- vec ) first3 v- nip ; -! -! : polygon-normal ( { v0 v1 v2 } -- normal ) dup v0-v1 swap v1-v2 cross ; +: polygon-normal ( {_v0_v1_v2_} -- normal ) first3 dupd v- -rot v- swap cross ; : (polygon) ( vertices -- ) GL_POLYGON glBegin dup polygon-normal gl-normal [ gl-vertex ] each glEnd ;