diff --git a/doc/_downloads/Frame.lpy b/doc/_downloads/Frame.lpy new file mode 100644 index 00000000..425edc31 --- /dev/null +++ b/doc/_downloads/Frame.lpy @@ -0,0 +1,11 @@ + +Axiom: Frame + +derivation length: 1 +production: + + +interpretation: + + +endlsystem diff --git a/doc/_downloads/InterpolateColors.lpy b/doc/_downloads/InterpolateColors.lpy new file mode 100644 index 00000000..2ac6994b --- /dev/null +++ b/doc/_downloads/InterpolateColors.lpy @@ -0,0 +1,32 @@ +#First Example + +Step = 20 +DIncr = 1.0 / Step + +Axiom: + d = 0.0 + for i in range(Step): + nproduce InterpolateColors(3, 5, d) F(2.0 / Step) + d += DIncr + produce ;(2) @O(0.15) + +#Second Example + +#Step = 4 +#DIncr = 1.0 / Step + +#Axiom: +# d = 0.0 +# for i in range(Step): +# nproduce InterpolateColors(2, 6, d) F(2.0 /Step) +# d += DIncr +# produce ;(1) @O(0.15) + +derivation length: 1 +production: + + +interpretation: + + +endlsystem diff --git a/doc/_downloads/LineTo.lpy b/doc/_downloads/LineTo.lpy new file mode 100644 index 00000000..84663153 --- /dev/null +++ b/doc/_downloads/LineTo.lpy @@ -0,0 +1,21 @@ +Axiom: LineTo(0,0,3)[LineTo(0,1,4)]LineTo(0,0,5) + +Axiom: LineTo(0,0,3)[+(90)LineTo(0,1,4)]-(30)LineTo(0,0,5) + +#Axiom: LineTo(0,0,2)[LineTo(0,1,3)Frame]LineTo(0,0,3)[LineTo(0,-1,4)Frame]LineTo(0,0,5) +#Same but change the turtle's orientation on the branches +#Axiom: LineTo(0,0,2)[OLineTo(0,1,3)Frame]LineTo(0,0,3)[OLineTo(0,-1,4)Frame]LineTo(0,0,5) + +#The branch is created from (0,0,2) to (0,1,2) +#Axiom: LineTo(0,0,2)[LineTo(0,1,2)]LineTo(0,0,4) +#The branch is created from (0,0,2) to (0,0+1,2+2) +#Axiom: LineTo(0,0,2)[LineRel(0,1,2)]LineTo(0,0,4) + +derivation length: 1 +production: + + +interpretation: + + +endlsystem diff --git a/doc/_downloads/advancedRotations.lpy b/doc/_downloads/advancedRotations.lpy new file mode 100644 index 00000000..4c654c08 --- /dev/null +++ b/doc/_downloads/advancedRotations.lpy @@ -0,0 +1,13 @@ +Axiom: Frame(2) | Frame(2) +#Axiom: Frame(2) UpReflexion Frame(2) +#Axiom: Frame(2) LeftReflexion Frame(2) +#Axiom: Frame(2) HeadingReflexion Frame(2) + +derivation length: 1 +production: + + +interpretation: + + +endlsystem diff --git a/doc/_downloads/basicShapes.lpy b/doc/_downloads/basicShapes.lpy new file mode 100644 index 00000000..e4972648 --- /dev/null +++ b/doc/_downloads/basicShapes.lpy @@ -0,0 +1,20 @@ +#Draw a sphere of radius 1 +Axiom: @O(1) +#Draw a circle of radius 1 +#Axiom: @o(1) +#Draw a box of length 1 +#Axiom: @B(1) +#Draw a quad of length 1 +#Axiom: @b(1) + +#Display some text +#Axiom: @L("This is some text", 18) + +derivation length: 1 +production: + + +interpretation: + + +endlsystem diff --git a/doc/_downloads/branching.lpy b/doc/_downloads/branching.lpy new file mode 100644 index 00000000..df8a8131 --- /dev/null +++ b/doc/_downloads/branching.lpy @@ -0,0 +1,17 @@ +#Simple branching +Axiom: F(4)[+F(3)]F(4) +#More branches +#Axiom: F(4)[+F(2)[+F(1)]F(1)]F(3)[-F(1)]F(1) +#Visualizing the frames at different steps +#Axiom: Frame F(4)[+F(2)[+F(1)Frame]F(1)]FrameF(3)[-F(1)]F(1) +#Combined with other primitives +#Axiom: F(4)[+F(2)[+F(1);(3)@O(0.2)]F(1);(3)@O(0.2)]F(3)[-F(1);(3)@O(0.2)]F(1);(3)@O(0.2) + +derivation length: 1 +production: + + +interpretation: + + +endlsystem diff --git a/doc/_downloads/combined.lpy b/doc/_downloads/combined.lpy new file mode 100644 index 00000000..c8b40e30 --- /dev/null +++ b/doc/_downloads/combined.lpy @@ -0,0 +1,12 @@ +Axiom: F[;+~l]F[;-~l]F[;+~l]F[;-~l]F[;+~l]F[;-~l]F + +#Axiom: ;@B(5),@O(0.5)_(0.5)F(3,0.5)_(0.2)@O(0.5) + +derivation length: 1 +production: + + +interpretation: + + +endlsystem diff --git a/doc/_downloads/filledPolygons.lpy b/doc/_downloads/filledPolygons.lpy new file mode 100644 index 00000000..8ad0d996 --- /dev/null +++ b/doc/_downloads/filledPolygons.lpy @@ -0,0 +1,27 @@ +#Drawing filled polygons + +#Using f. +Axiom: Frame _(0.05),(2){.f(3).-(90)f(3).-(90)f(3).-(90)f(3)} +#Using F +#Axiom: Frame _(0.05),(2){.F(3)-(90)F(3)-(90)F(3)-(90)F(3)} +#With number of edges different than number of vertices +#Axiom: Frame _(0.05),(2){.F(3)-(90)F(3)-(90)F(3)} +#Not closed because the first . is missing +#Axiom: Frame _(0.05),(2){F(3)-(90)F(3)-(90)F(3)} + +#Smart filling procedure + +#Without smart procedure +#Axiom: _(0.01),(2) {.F+(95)F(0.7)-(120)F(0.2)+(80)F-(120)F(0.2)+(80)F(0.5)-120)F(0.5)+(80)F(0.2)-(120)F(0.5)+(150)F-(120)F(0.3)+(80)F -(120)F+(80)F(0.3)-(120)F +(150)F(0.5)-(120)F(0.2)+(80)F(0.5)-(120)F(0.5)+(80)F(0.2)-(120)F+(20)F(0.2)-(150)F(0.7)+(95)F}(False) + +#With smart procedure +#Axiom: _(0.01),(2) {.F+(95)F(0.7)-(120)F(0.2)+(80)F-(120)F(0.2)+(80)F(0.5)-(120)F(0.5)+(80)F(0.2)-(120)F(0.5)+(150)F-(120)F(0.3)+(80)F -(120)F+(80)F(0.3)-(120)F +(150)F(0.5)-(120)F(0.2)+(80)F(0.5)-(120)F(0.5)+(80)F(0.2)-(120)F+(120)F(0.2)-(150)F(0.7)+(95)F}(True) + +derivation length: 1 +production: + + +interpretation: + + +endlsystem diff --git a/doc/_downloads/generalizedCylinders.lpy b/doc/_downloads/generalizedCylinders.lpy new file mode 100644 index 00000000..be5938f8 --- /dev/null +++ b/doc/_downloads/generalizedCylinders.lpy @@ -0,0 +1,14 @@ +#Cylinders not generalized +Axiom: F(2)+(30)F+(30)F+(30)F+(45)F+(45)F@O + +#Cylinders generalized +#Axiom: @GcF(2)+(30)F+(30)F+(30)F+(45)F+(45)F@O@Ge + +derivation length: 1 +production: + + +interpretation: + + +endlsystem diff --git a/doc/_downloads/harderExample.lpy b/doc/_downloads/harderExample.lpy new file mode 100644 index 00000000..d27f2d52 --- /dev/null +++ b/doc/_downloads/harderExample.lpy @@ -0,0 +1,10 @@ +Axiom: F[;-(70)f(0.1)\(80)~l]F[;+(70)f(0.1)/(80)~l][-F[;+(100)f(0.1)/(80)~l][F(1.2);@O(0.2)]-F(0.6)[-f(0.4);(3)@O(0.3)]F(0.6);@O(0.2)]F(1.5)[;+(70)f(0.1)/(70)~l]F(0.1)[+F;@O(0.2)]F;@O(0.2) + +derivation length: 1 +production: + + +interpretation: + + +endlsystem diff --git a/doc/_downloads/longPath.lpy b/doc/_downloads/longPath.lpy new file mode 100644 index 00000000..e6a6e190 --- /dev/null +++ b/doc/_downloads/longPath.lpy @@ -0,0 +1,14 @@ +#Equivalent to FF+(20)FF+(20)@D(0.8)FFF +Axiom: nF(2,1)+(20)nF(2,1)+(20)@D(0.8)nF(3,1) + +#Branching shape +#Axiom: nF(2,1)[+(45)nF(2,1)]nF(1,1)[-(45)nF(2,1)]nF(2,1) + +derivation length: 1 +production: + + +interpretation: + + +endlsystem diff --git a/doc/_downloads/movement.lpy b/doc/_downloads/movement.lpy new file mode 100644 index 00000000..e62212ca --- /dev/null +++ b/doc/_downloads/movement.lpy @@ -0,0 +1,20 @@ +#MoveTo using coordinates +Axiom: @M(0,2,0) Frame + +#MoveTo using a vector +#import numpy as np +#v = np.array([0,1,1]) +#Axiom: MoveTo(v) + +#MoveRel +#Axiom: F MoveTo(0,3,0) Frame +#Axiom: F MoveRel(0,3,0) Frame + +derivation length: 1 +production: + + +interpretation: + + +endlsystem diff --git a/doc/_downloads/orientation.lpy b/doc/_downloads/orientation.lpy new file mode 100644 index 00000000..8aef0efe --- /dev/null +++ b/doc/_downloads/orientation.lpy @@ -0,0 +1,21 @@ +#Orient the turtle using coordinates +Axiom: Pinpoint(1,0,0) Frame +#Orient the turtle using a vector +#import numpy as np +#v = np.array([0,1,0]) +#Axiom: Pinpoint(v) Frame +#Another example +#Axiom: Pinpoint(1,1,0) Frame + +#PinpointRel +#Axiom: Frame MoveTo(0,2,0) Pinpoint(1,0,1) Frame +#Axiom: Frame MoveTo(0,2,0) PinpointRel(1,0,1) Frame + +derivation length: 1 +production: + + +interpretation: + + +endlsystem diff --git a/doc/_downloads/polygons.lpy b/doc/_downloads/polygons.lpy new file mode 100644 index 00000000..26f4b74c --- /dev/null +++ b/doc/_downloads/polygons.lpy @@ -0,0 +1,18 @@ +#Basic method +Axiom: Frame(2)+(30)F(5)+(120)F(5)+(120)F(5) +#Procedural method +#Axiom: Frame(2)+F(5)+F(5)+F(5)+F(5)+F(5)+F(5) +# Or equivalently: +#Axiom: +# nproduce Frame(2) +# for i in range(6): +# nproduce +F(5) + +derivation length: 1 +production: + + +interpretation: + + +endlsystem diff --git a/doc/_downloads/resolution.lpy b/doc/_downloads/resolution.lpy new file mode 100644 index 00000000..1fadac6b --- /dev/null +++ b/doc/_downloads/resolution.lpy @@ -0,0 +1,13 @@ +#low resolution +Axiom: SectionResolution(4) FFF@O(0.5) +#better resolution +#Axiom: SectionResolution(60) FFF@O(0.5) + +derivation length: 1 +production: + + +interpretation: + + +endlsystem diff --git a/doc/_downloads/rotation.lpy b/doc/_downloads/rotation.lpy new file mode 100644 index 00000000..e1b63d0e --- /dev/null +++ b/doc/_downloads/rotation.lpy @@ -0,0 +1,16 @@ +#Different turtle rotations +Axiom: Frame(2) /(60) Frame(2) +#Axiom: Frame(2) \(60) Frame(2) +#Axiom: Frame(2) ^(60) Frame(2) +#Axiom: Frame(2) &(60) Frame(2) +#Axiom: Frame(2) +(60) Frame(2) +#Axiom: Frame(2) -(60) Frame(2) + +derivation length: 1 +production: + + +interpretation: + + +endlsystem diff --git a/doc/_downloads/scale.lpy b/doc/_downloads/scale.lpy new file mode 100644 index 00000000..66324a3e --- /dev/null +++ b/doc/_downloads/scale.lpy @@ -0,0 +1,12 @@ +Axiom: FF[-F[-F]F]FF + +#Axiom: @D(2)FF[@Dd(1.5)-F[@Di(0.5)-F]F]FF + +derivation length: 1 +production: + + +interpretation: + + +endlsystem diff --git a/doc/_downloads/screen.lpy b/doc/_downloads/screen.lpy new file mode 100644 index 00000000..044035ad --- /dev/null +++ b/doc/_downloads/screen.lpy @@ -0,0 +1,10 @@ +Axiom: Frame @2DF(0.6)@O(0.2) + +derivation length: 1 +production: + + +interpretation: + + +endlsystem diff --git a/doc/_downloads/setGuide1.lpy b/doc/_downloads/setGuide1.lpy new file mode 100644 index 00000000..dfb19984 --- /dev/null +++ b/doc/_downloads/setGuide1.lpy @@ -0,0 +1,22 @@ +from openalea.plantgl.all import Polyline2D +from numpy import arange + +def f(u): + return (u,u**2) + +C0 = Polyline2D([f(u) for u in arange(0,1,0.1)]) # (B) + +L = 10 +#L = 6 +#L = 15 +L0 = 10 +Axiom: SetGuide(C0,L0) nF(L, 0.1) + +derivation length: 1 +production: + + +interpretation: + + +endlsystem diff --git a/doc/_downloads/setGuide2.lpy b/doc/_downloads/setGuide2.lpy new file mode 100644 index 00000000..fd6833ab --- /dev/null +++ b/doc/_downloads/setGuide2.lpy @@ -0,0 +1,31 @@ +L = 10 +#L = 6 +#L = 15 +L0 = 10 +Axiom: Frame SetGuide(C0,L0) nF(L, 0.1) +#Axiom: Sweep(C0,C0,7,1) + +derivation length: 1 +production: + + +interpretation: + + +endlsystem +###### INITIALISATION ###### + +__lpy_code_version__ = 1.1 + +def __initialiseContext__(context): + import openalea.plantgl.all as pgl + C0 = pgl.BezierCurve2D( + pgl.Point3Array([(-0.5, 0, 1),(-0.171072, 0.38326, 1),(0.00367107, -0.317181, 1),(0.5, 0, 1)]) , + ) + C0.name = "C0" + panel_0 = ({'active': True, 'visible': True, 'name': 'Panel 1'},[('Curve2D',C0)]) + parameterset = [panel_0,] + context["__functions__"] = [] + context["__curves__"] = [('C0',C0),] + context["__parameterset__"] = parameterset + context["C0"] = C0 diff --git a/doc/_downloads/setHLU.lpy b/doc/_downloads/setHLU.lpy new file mode 100644 index 00000000..4810277c --- /dev/null +++ b/doc/_downloads/setHLU.lpy @@ -0,0 +1,31 @@ +#Setting the HLU +#Using coordinates +Axiom: Frame(2) @R(1,1,1,0,1,0) Frame(2) +#using vectors +#import numpy as np +#h = np.array([0,1,0]) +#u = np.array([1,0,1]) +#Axiom: @R(h,u) Frame(2) + +#Using Euler Angles + +#Axiom: EulerAngles(0,0,0) Frame(2) +#Axiom: EulerAngles(180,0,0) Frame(2) +#Axiom: EulerAngles(180,90,0) Frame(2) + +#3 rotations to arrive to (30,90,60) +#First : +#Axiom: EulerAngles(30,0,0) Frame(2) +#Then : +#Axiom: EulerAngles(30,90,0) Frame(2) +#Finally : +#Axiom: EulerAngles(30,90,60) Frame(2) + +derivation length: 1 +production: + + +interpretation: + + +endlsystem diff --git a/doc/_downloads/tropism.lpy b/doc/_downloads/tropism.lpy new file mode 100644 index 00000000..5e59f4a2 --- /dev/null +++ b/doc/_downloads/tropism.lpy @@ -0,0 +1,16 @@ +#Elasticity +#Axiom: FF[Elasticity(0.5)+F+F]F[-F]F + +#Tropism +import numpy as np +v = np.array([0,1,2]) +Axiom: FF[@Tp(v)+F+F]F[-F]F + +derivation length: 1 +production: + + +interpretation: + + +endlsystem diff --git a/doc/_downloads/visualize.lpy b/doc/_downloads/visualize.lpy new file mode 100644 index 00000000..3f9fde33 --- /dev/null +++ b/doc/_downloads/visualize.lpy @@ -0,0 +1,14 @@ +#Without Frames +Axiom: FF[+ FF]FFF + +#With Frames +#Axiom: Frame FF[+ FF Frame ]F Frame FF + +derivation length: 1 +production: + + +interpretation: + + +endlsystem diff --git a/doc/_downloads/width.lpy b/doc/_downloads/width.lpy new file mode 100644 index 00000000..d2562c70 --- /dev/null +++ b/doc/_downloads/width.lpy @@ -0,0 +1,14 @@ +#Increase then decrease the width +#Axiom: F_ _ _F!F!F + +#Set the width to 2 then to 3 and finally to 1 +Axiom: F_(2)F!(3)F!(1)F + +derivation length: 1 +production: + + +interpretation: + + +endlsystem diff --git a/doc/_images/2D1.png b/doc/_images/2D1.png new file mode 100644 index 00000000..3656662f Binary files /dev/null and b/doc/_images/2D1.png differ diff --git a/doc/_images/2D2.png b/doc/_images/2D2.png new file mode 100644 index 00000000..b397197e Binary files /dev/null and b/doc/_images/2D2.png differ diff --git a/doc/_images/@R.png b/doc/_images/@R.png new file mode 100644 index 00000000..b5feee97 Binary files /dev/null and b/doc/_images/@R.png differ diff --git a/doc/_images/@R2.png b/doc/_images/@R2.png new file mode 100644 index 00000000..3d8c615a Binary files /dev/null and b/doc/_images/@R2.png differ diff --git a/doc/_images/F-.png b/doc/_images/F-.png new file mode 100644 index 00000000..14588a08 Binary files /dev/null and b/doc/_images/F-.png differ diff --git a/doc/_images/F2,5.png b/doc/_images/F2,5.png new file mode 100644 index 00000000..c6169411 Binary files /dev/null and b/doc/_images/F2,5.png differ diff --git a/doc/_images/F3.png b/doc/_images/F3.png new file mode 100644 index 00000000..e4fdee86 Binary files /dev/null and b/doc/_images/F3.png differ diff --git a/doc/_images/LineRel1.png b/doc/_images/LineRel1.png new file mode 100644 index 00000000..4cc4f244 Binary files /dev/null and b/doc/_images/LineRel1.png differ diff --git a/doc/_images/LineRel2.png b/doc/_images/LineRel2.png new file mode 100644 index 00000000..b8a3b207 Binary files /dev/null and b/doc/_images/LineRel2.png differ diff --git a/doc/_images/LineTo.png b/doc/_images/LineTo.png new file mode 100644 index 00000000..71bcad58 Binary files /dev/null and b/doc/_images/LineTo.png differ diff --git a/doc/_images/LineTo2.png b/doc/_images/LineTo2.png new file mode 100644 index 00000000..2f2d9075 Binary files /dev/null and b/doc/_images/LineTo2.png differ diff --git a/doc/_images/LineToBis.png b/doc/_images/LineToBis.png new file mode 100644 index 00000000..9e8b3238 Binary files /dev/null and b/doc/_images/LineToBis.png differ diff --git a/doc/_images/OLineTo.png b/doc/_images/OLineTo.png new file mode 100644 index 00000000..efb633c2 Binary files /dev/null and b/doc/_images/OLineTo.png differ diff --git a/doc/_images/_F.png b/doc/_images/_F.png new file mode 100644 index 00000000..3d4370ab Binary files /dev/null and b/doc/_images/_F.png differ diff --git a/doc/_images/axis.png b/doc/_images/axis.png new file mode 100644 index 00000000..43d9d5ff Binary files /dev/null and b/doc/_images/axis.png differ diff --git a/doc/_images/basicPolygon.png b/doc/_images/basicPolygon.png new file mode 100644 index 00000000..0ba55a48 Binary files /dev/null and b/doc/_images/basicPolygon.png differ diff --git a/doc/_images/box.png b/doc/_images/box.png new file mode 100644 index 00000000..fa209b8e Binary files /dev/null and b/doc/_images/box.png differ diff --git a/doc/_images/branch.png b/doc/_images/branch.png new file mode 100644 index 00000000..e9db1b93 Binary files /dev/null and b/doc/_images/branch.png differ diff --git a/doc/_images/branching1.png b/doc/_images/branching1.png new file mode 100644 index 00000000..01393077 Binary files /dev/null and b/doc/_images/branching1.png differ diff --git a/doc/_images/branching2.png b/doc/_images/branching2.png new file mode 100644 index 00000000..72f7f2f7 Binary files /dev/null and b/doc/_images/branching2.png differ diff --git a/doc/_images/branching3.png b/doc/_images/branching3.png new file mode 100644 index 00000000..01d6c20a Binary files /dev/null and b/doc/_images/branching3.png differ diff --git a/doc/_images/circle.png b/doc/_images/circle.png new file mode 100644 index 00000000..39fa4c41 Binary files /dev/null and b/doc/_images/circle.png differ diff --git a/doc/_images/combined.png b/doc/_images/combined.png new file mode 100644 index 00000000..ddde6f60 Binary files /dev/null and b/doc/_images/combined.png differ diff --git a/doc/_images/combined2.png b/doc/_images/combined2.png new file mode 100644 index 00000000..d86e9cf7 Binary files /dev/null and b/doc/_images/combined2.png differ diff --git a/doc/_images/decrease_color.png b/doc/_images/decrease_color.png new file mode 100644 index 00000000..951c844b Binary files /dev/null and b/doc/_images/decrease_color.png differ diff --git a/doc/_images/divScale.png b/doc/_images/divScale.png new file mode 100644 index 00000000..eaef784a Binary files /dev/null and b/doc/_images/divScale.png differ diff --git a/doc/_images/downArroundL.png b/doc/_images/downArroundL.png new file mode 100644 index 00000000..99b01232 Binary files /dev/null and b/doc/_images/downArroundL.png differ diff --git a/doc/_images/euler.png b/doc/_images/euler.png new file mode 100644 index 00000000..6d8d3eaf Binary files /dev/null and b/doc/_images/euler.png differ diff --git a/doc/_images/euler2.png b/doc/_images/euler2.png new file mode 100644 index 00000000..8df97df0 Binary files /dev/null and b/doc/_images/euler2.png differ diff --git a/doc/_images/euler3.png b/doc/_images/euler3.png new file mode 100644 index 00000000..e6d5895c Binary files /dev/null and b/doc/_images/euler3.png differ diff --git a/doc/_images/euler4.png b/doc/_images/euler4.png new file mode 100644 index 00000000..453ea67d Binary files /dev/null and b/doc/_images/euler4.png differ diff --git a/doc/_images/euler5.png b/doc/_images/euler5.png new file mode 100644 index 00000000..53595ae4 Binary files /dev/null and b/doc/_images/euler5.png differ diff --git a/doc/_images/euler6.png b/doc/_images/euler6.png new file mode 100644 index 00000000..f86b3019 Binary files /dev/null and b/doc/_images/euler6.png differ diff --git a/doc/_images/ex001.png b/doc/_images/ex001.png deleted file mode 100644 index 7a89f988..00000000 Binary files a/doc/_images/ex001.png and /dev/null differ diff --git a/doc/_images/ex002.png b/doc/_images/ex002.png deleted file mode 100644 index 98d2bd99..00000000 Binary files a/doc/_images/ex002.png and /dev/null differ diff --git a/doc/_images/ex003.png b/doc/_images/ex003.png deleted file mode 100644 index 129f62c0..00000000 Binary files a/doc/_images/ex003.png and /dev/null differ diff --git a/doc/_images/ex004.png b/doc/_images/ex004.png deleted file mode 100644 index c8ca697f..00000000 Binary files a/doc/_images/ex004.png and /dev/null differ diff --git a/doc/_images/ex005.png b/doc/_images/ex005.png deleted file mode 100644 index 6762e256..00000000 Binary files a/doc/_images/ex005.png and /dev/null differ diff --git a/doc/_images/ex006.png b/doc/_images/ex006.png deleted file mode 100644 index 8af2231a..00000000 Binary files a/doc/_images/ex006.png and /dev/null differ diff --git a/doc/_images/ex007.png b/doc/_images/ex007.png deleted file mode 100644 index 02a5c9c7..00000000 Binary files a/doc/_images/ex007.png and /dev/null differ diff --git a/doc/_images/ex008.png b/doc/_images/ex008.png deleted file mode 100644 index 996aaac4..00000000 Binary files a/doc/_images/ex008.png and /dev/null differ diff --git a/doc/_images/ex010.png b/doc/_images/ex010.png deleted file mode 100644 index 90349a46..00000000 Binary files a/doc/_images/ex010.png and /dev/null differ diff --git a/doc/_images/ex011.png b/doc/_images/ex011.png deleted file mode 100644 index 20cd7cc1..00000000 Binary files a/doc/_images/ex011.png and /dev/null differ diff --git a/doc/_images/ex012.png b/doc/_images/ex012.png deleted file mode 100644 index b5b367bd..00000000 Binary files a/doc/_images/ex012.png and /dev/null differ diff --git a/doc/_images/ex013.png b/doc/_images/ex013.png deleted file mode 100644 index 39c962ea..00000000 Binary files a/doc/_images/ex013.png and /dev/null differ diff --git a/doc/_images/f.png b/doc/_images/f.png new file mode 100644 index 00000000..dab7a3a6 Binary files /dev/null and b/doc/_images/f.png differ diff --git a/doc/_images/f2.png b/doc/_images/f2.png new file mode 100644 index 00000000..b66581c6 Binary files /dev/null and b/doc/_images/f2.png differ diff --git a/doc/_images/filledPolygon1.png b/doc/_images/filledPolygon1.png new file mode 100644 index 00000000..44bcde22 Binary files /dev/null and b/doc/_images/filledPolygon1.png differ diff --git a/doc/_images/filledPolygon2.png b/doc/_images/filledPolygon2.png new file mode 100644 index 00000000..8f5e70f8 Binary files /dev/null and b/doc/_images/filledPolygon2.png differ diff --git a/doc/_images/filledPolygon3.png b/doc/_images/filledPolygon3.png new file mode 100644 index 00000000..5916b9e5 Binary files /dev/null and b/doc/_images/filledPolygon3.png differ diff --git a/doc/_images/filledPolygon4.png b/doc/_images/filledPolygon4.png new file mode 100644 index 00000000..cc0df580 Binary files /dev/null and b/doc/_images/filledPolygon4.png differ diff --git a/doc/_images/frame.png b/doc/_images/frame.png new file mode 100644 index 00000000..bac4e5f4 Binary files /dev/null and b/doc/_images/frame.png differ diff --git a/doc/_images/generalized.png b/doc/_images/generalized.png new file mode 100644 index 00000000..52e18a12 Binary files /dev/null and b/doc/_images/generalized.png differ diff --git a/doc/_images/harderExample.png b/doc/_images/harderExample.png new file mode 100644 index 00000000..c195df29 Binary files /dev/null and b/doc/_images/harderExample.png differ diff --git a/doc/_images/increase_color.png b/doc/_images/increase_color.png new file mode 100644 index 00000000..ee3d0b22 Binary files /dev/null and b/doc/_images/increase_color.png differ diff --git a/doc/_images/initialScale.png b/doc/_images/initialScale.png new file mode 100644 index 00000000..c151edb0 Binary files /dev/null and b/doc/_images/initialScale.png differ diff --git a/doc/_images/interpolateColors.png b/doc/_images/interpolateColors.png new file mode 100644 index 00000000..d5dc9108 Binary files /dev/null and b/doc/_images/interpolateColors.png differ diff --git a/doc/_images/interpolateColors2.png b/doc/_images/interpolateColors2.png new file mode 100644 index 00000000..bed8e662 Binary files /dev/null and b/doc/_images/interpolateColors2.png differ diff --git a/doc/_images/leaf.png b/doc/_images/leaf.png new file mode 100644 index 00000000..21844c0b Binary files /dev/null and b/doc/_images/leaf.png differ diff --git a/doc/_images/leaf1.png b/doc/_images/leaf1.png new file mode 100644 index 00000000..3ace706d Binary files /dev/null and b/doc/_images/leaf1.png differ diff --git a/doc/_images/leaf2.png b/doc/_images/leaf2.png new file mode 100644 index 00000000..17915d15 Binary files /dev/null and b/doc/_images/leaf2.png differ diff --git a/doc/_images/leftArroundH.png b/doc/_images/leftArroundH.png new file mode 100644 index 00000000..22e0e854 Binary files /dev/null and b/doc/_images/leftArroundH.png differ diff --git a/doc/_images/leftArroundU.png b/doc/_images/leftArroundU.png new file mode 100644 index 00000000..64263028 Binary files /dev/null and b/doc/_images/leftArroundU.png differ diff --git a/doc/_images/loopPolygon.png b/doc/_images/loopPolygon.png new file mode 100644 index 00000000..db6646b9 Binary files /dev/null and b/doc/_images/loopPolygon.png differ diff --git a/doc/_images/moveRel1.png b/doc/_images/moveRel1.png new file mode 100644 index 00000000..c158e8a6 Binary files /dev/null and b/doc/_images/moveRel1.png differ diff --git a/doc/_images/moveRel2.png b/doc/_images/moveRel2.png new file mode 100644 index 00000000..5019525c Binary files /dev/null and b/doc/_images/moveRel2.png differ diff --git a/doc/_images/moveTo1.png b/doc/_images/moveTo1.png new file mode 100644 index 00000000..d7e32331 Binary files /dev/null and b/doc/_images/moveTo1.png differ diff --git a/doc/_images/moveTo2.png b/doc/_images/moveTo2.png new file mode 100644 index 00000000..dbd2fc27 Binary files /dev/null and b/doc/_images/moveTo2.png differ diff --git a/doc/_images/multScale.png b/doc/_images/multScale.png new file mode 100644 index 00000000..fb0e8c77 Binary files /dev/null and b/doc/_images/multScale.png differ diff --git a/doc/_images/notGeneralized.png b/doc/_images/notGeneralized.png new file mode 100644 index 00000000..76ea313e Binary files /dev/null and b/doc/_images/notGeneralized.png differ diff --git a/doc/_images/path.png b/doc/_images/path.png new file mode 100644 index 00000000..5a9ae82d Binary files /dev/null and b/doc/_images/path.png differ diff --git a/doc/_images/path2.png b/doc/_images/path2.png new file mode 100644 index 00000000..5d19b9bc Binary files /dev/null and b/doc/_images/path2.png differ diff --git a/doc/_images/pinpoint1.png b/doc/_images/pinpoint1.png new file mode 100644 index 00000000..4bebdbd3 Binary files /dev/null and b/doc/_images/pinpoint1.png differ diff --git a/doc/_images/pinpoint2.png b/doc/_images/pinpoint2.png new file mode 100644 index 00000000..f494aed6 Binary files /dev/null and b/doc/_images/pinpoint2.png differ diff --git a/doc/_images/pinpoint3.png b/doc/_images/pinpoint3.png new file mode 100644 index 00000000..c7bf959a Binary files /dev/null and b/doc/_images/pinpoint3.png differ diff --git a/doc/_images/pinpointRel1.png b/doc/_images/pinpointRel1.png new file mode 100644 index 00000000..be8348ef Binary files /dev/null and b/doc/_images/pinpointRel1.png differ diff --git a/doc/_images/pinpointRel2.png b/doc/_images/pinpointRel2.png new file mode 100644 index 00000000..335f6f19 Binary files /dev/null and b/doc/_images/pinpointRel2.png differ diff --git a/doc/_images/quad.png b/doc/_images/quad.png new file mode 100644 index 00000000..c298077f Binary files /dev/null and b/doc/_images/quad.png differ diff --git a/doc/_images/rescaling.png b/doc/_images/rescaling.png new file mode 100644 index 00000000..984a233f Binary files /dev/null and b/doc/_images/rescaling.png differ diff --git a/doc/_images/resolution1.png b/doc/_images/resolution1.png new file mode 100644 index 00000000..afd01035 Binary files /dev/null and b/doc/_images/resolution1.png differ diff --git a/doc/_images/resolution2.png b/doc/_images/resolution2.png new file mode 100644 index 00000000..330ca24e Binary files /dev/null and b/doc/_images/resolution2.png differ diff --git a/doc/_images/rightArroundH.png b/doc/_images/rightArroundH.png new file mode 100644 index 00000000..f6ce387a Binary files /dev/null and b/doc/_images/rightArroundH.png differ diff --git a/doc/_images/rightArroundU.png b/doc/_images/rightArroundU.png new file mode 100644 index 00000000..db6732cc Binary files /dev/null and b/doc/_images/rightArroundU.png differ diff --git a/doc/_images/rotation1.png b/doc/_images/rotation1.png new file mode 100644 index 00000000..84813f62 Binary files /dev/null and b/doc/_images/rotation1.png differ diff --git a/doc/_images/rotation2.png b/doc/_images/rotation2.png new file mode 100644 index 00000000..02347b01 Binary files /dev/null and b/doc/_images/rotation2.png differ diff --git a/doc/_images/rotation3.png b/doc/_images/rotation3.png new file mode 100644 index 00000000..5950ed67 Binary files /dev/null and b/doc/_images/rotation3.png differ diff --git a/doc/_images/rotation4.png b/doc/_images/rotation4.png new file mode 100644 index 00000000..496d23c1 Binary files /dev/null and b/doc/_images/rotation4.png differ diff --git a/doc/_images/rotation5.png b/doc/_images/rotation5.png new file mode 100644 index 00000000..2e425296 Binary files /dev/null and b/doc/_images/rotation5.png differ diff --git a/doc/_images/rotation6.png b/doc/_images/rotation6.png new file mode 100644 index 00000000..2fc5fdd9 Binary files /dev/null and b/doc/_images/rotation6.png differ diff --git a/doc/_images/setColor1.png b/doc/_images/setColor1.png new file mode 100644 index 00000000..8413d446 Binary files /dev/null and b/doc/_images/setColor1.png differ diff --git a/doc/_images/setColor2.png b/doc/_images/setColor2.png new file mode 100644 index 00000000..0bc23f71 Binary files /dev/null and b/doc/_images/setColor2.png differ diff --git a/doc/_images/setGuide1.png b/doc/_images/setGuide1.png new file mode 100644 index 00000000..bea4f228 Binary files /dev/null and b/doc/_images/setGuide1.png differ diff --git a/doc/_images/setGuide2.png b/doc/_images/setGuide2.png new file mode 100644 index 00000000..54a12084 Binary files /dev/null and b/doc/_images/setGuide2.png differ diff --git a/doc/_images/setGuide3.png b/doc/_images/setGuide3.png new file mode 100644 index 00000000..e05f2a71 Binary files /dev/null and b/doc/_images/setGuide3.png differ diff --git a/doc/_images/setGuide4.png b/doc/_images/setGuide4.png new file mode 100644 index 00000000..8c4ed1c8 Binary files /dev/null and b/doc/_images/setGuide4.png differ diff --git a/doc/_images/setGuide5.png b/doc/_images/setGuide5.png new file mode 100644 index 00000000..334b5ab1 Binary files /dev/null and b/doc/_images/setGuide5.png differ diff --git a/doc/_images/sphere.png b/doc/_images/sphere.png new file mode 100644 index 00000000..a3c21c99 Binary files /dev/null and b/doc/_images/sphere.png differ diff --git a/doc/_images/square.png b/doc/_images/square.png new file mode 100644 index 00000000..19eac0b2 Binary files /dev/null and b/doc/_images/square.png differ diff --git a/doc/_images/turnAround.png b/doc/_images/turnAround.png new file mode 100644 index 00000000..03ee665f Binary files /dev/null and b/doc/_images/turnAround.png differ diff --git a/doc/_images/turtle1.png b/doc/_images/turtle1.png new file mode 100644 index 00000000..0d6da319 Binary files /dev/null and b/doc/_images/turtle1.png differ diff --git a/doc/_images/turtle2.png b/doc/_images/turtle2.png new file mode 100644 index 00000000..1fdf8fa9 Binary files /dev/null and b/doc/_images/turtle2.png differ diff --git a/doc/_images/turtle3.png b/doc/_images/turtle3.png new file mode 100644 index 00000000..a58cc105 Binary files /dev/null and b/doc/_images/turtle3.png differ diff --git a/doc/_images/turtle4.png b/doc/_images/turtle4.png new file mode 100644 index 00000000..4e0cab1d Binary files /dev/null and b/doc/_images/turtle4.png differ diff --git a/doc/_images/upArroundL.png b/doc/_images/upArroundL.png new file mode 100644 index 00000000..1f234531 Binary files /dev/null and b/doc/_images/upArroundL.png differ diff --git a/doc/_images/width.png b/doc/_images/width.png new file mode 100644 index 00000000..4e27ad88 Binary files /dev/null and b/doc/_images/width.png differ diff --git a/doc/_images/width2.png b/doc/_images/width2.png new file mode 100644 index 00000000..55a569c7 Binary files /dev/null and b/doc/_images/width2.png differ diff --git a/doc/_images/with_frame.png b/doc/_images/with_frame.png new file mode 100644 index 00000000..9558b758 Binary files /dev/null and b/doc/_images/with_frame.png differ diff --git a/doc/index.rst b/doc/index.rst index dd5151a9..c2c03340 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -32,7 +32,9 @@ Documentation ./user/lsystems.rst ./user/filesyntax.rst ./user/editor.rst - ./user/turtle.rst + ./user/turtleBasic.rst + ./user/turtleAdvanced.rst + ./user/tutorial.rst ./user/subtelties.rst ./user/helpcard.rst ./user/integration.rst diff --git a/doc/predef_com.helpcard b/doc/predef_com.helpcard index 62e6001f..8baca7ad 100644 --- a/doc/predef_com.helpcard +++ b/doc/predef_com.helpcard @@ -75,4 +75,4 @@ F. Boudon, T. Cokelaer, C. Pradal and C. Godin, L-Py, an open L-systems framewor P. Prusinkiewicz et al., 89, The algorithmic Beauty of Plants, Springer-Verlag. P. Prusinkiewicz. Graphical applications of L-systems. Proceedings of Graphics Interface '86, pp. 247-253. P. Prusinkiewicz, R. Karwowski, and B. Lane. The L+C plant modelling language. In Functional-Structural Plant Modelling in Crop Production, J. Vos et al. (eds.), Springer, 2007. -.list-end: \ No newline at end of file +.list-end: diff --git a/doc/user/helpcard.rst b/doc/user/helpcard.rst new file mode 100644 index 00000000..14cb5ec6 --- /dev/null +++ b/doc/user/helpcard.rst @@ -0,0 +1,373 @@ + +L-Py Helpcard +############# +L-Py is based on the specification of Lstudio/cpfg-lpfg defined by P. Prusinkiewicz et al. (http://algorithmicbotany.org/lstudio). + +Predefined Symbols +================== +Here is a recap of the predefined symbol used in L-Py with their turtle interpretation: + ++-+------+-------------+ +| | None | None Module.| ++-+------+-------------+ + +Structure +--------- + ++--+----+--------------------------------------------------------------------+ +|[ | SB | Push the state in the stack. | ++--+----+--------------------------------------------------------------------+ +|] | EB | Pop last state from turtle stack and make it the its current state.| ++--+----+--------------------------------------------------------------------+ + +Rotation +-------- + ++------------------+------------------+------------------------------------------------------------------------------------------------------------------------------------+ +|Pinpoint | | Orient turtle toward (x,y,z) . Params : 'x, y, z' or 'v' (optionals, default = 0). | ++------------------+------------------+------------------------------------------------------------------------------------------------------------------------------------+ +|PinpointRel | | Orient turtle toward pos+(x,y,z) . Params : 'x, y, z' or 'v' (optionals, default = 0). | ++------------------+------------------+------------------------------------------------------------------------------------------------------------------------------------+ +|@R | SetHead | Set the turtle Heading and Up vector. Params: 'hx, hy, hz, ux, uy, uz' or 'h,v' (optionals, default=0,0,1, 1,0,0). | ++------------------+------------------+------------------------------------------------------------------------------------------------------------------------------------+ +|EulerAngles | | Set the orientation of the turtle from the absolute euler angles. Params: 'azimuth, elevation, roll' (optionals, default=180,90,0).| ++------------------+------------------+------------------------------------------------------------------------------------------------------------------------------------+ +|+ | Left | Turn left around Up vector. Params : 'angle' (optional, in degrees). | ++------------------+------------------+------------------------------------------------------------------------------------------------------------------------------------+ +|- | Right | Turn right around Up vector. Params : 'angle' (optional, in degrees). | ++------------------+------------------+------------------------------------------------------------------------------------------------------------------------------------+ +|^ | Up | Pitch up around Left vector. Params : 'angle' (optional, in degrees). | ++------------------+------------------+------------------------------------------------------------------------------------------------------------------------------------+ +|& | Down | Pitch down around Left vector. Params : 'angle' (optional, in degrees). | ++------------------+------------------+------------------------------------------------------------------------------------------------------------------------------------+ +|/ | RollL | Roll left around Heading vector. Params : 'angle' (optional, in degrees). | ++------------------+------------------+------------------------------------------------------------------------------------------------------------------------------------+ +|\ | RollR | Roll right around Heading vector. Params : 'angle' (optional, in degrees). | ++------------------+------------------+------------------------------------------------------------------------------------------------------------------------------------+ +|iRollL | | Roll left intrinsically around Heading vector. Params : 'angle' (optional, in degrees). | ++------------------+------------------+------------------------------------------------------------------------------------------------------------------------------------+ +|iRollR | | Roll right intrinsically around Heading vector. Params : 'angle' (optional, in degrees). | ++------------------+------------------+------------------------------------------------------------------------------------------------------------------------------------+ +|| | TurnAround | Turn around 180deg the Up vector. | ++------------------+------------------+------------------------------------------------------------------------------------------------------------------------------------+ +|@v | RollToVert | Roll to Vertical : Roll the turtle around the H axis so that H and U lie in a common vertical plane with U closest to up | ++------------------+------------------+------------------------------------------------------------------------------------------------------------------------------------+ +|@h | RollToHorizontal | Roll to Horizontal : Roll the turtle so that H lie in the horizontal plane | ++------------------+------------------+------------------------------------------------------------------------------------------------------------------------------------+ +|LeftReflection | | The turtle change the left vector to have a symmetric behavior. | ++------------------+------------------+------------------------------------------------------------------------------------------------------------------------------------+ +|UpReflection | | The turtle change the up vector to have a symmetric behavior. | ++------------------+------------------+------------------------------------------------------------------------------------------------------------------------------------+ +|HeadingReflection | | The turtle change the heading vector to have a symmetric behavior. | ++------------------+------------------+------------------------------------------------------------------------------------------------------------------------------------+ + +Position +-------- + ++--------+-----------------------+----------------------------------------------------------------------------------------------------------------------+ +|@M | MoveTo | Set the turtle position. Params : 'x, y, z' or 'v' (optionals, default = None for not changing specific coordinates).| ++--------+-----------------------+----------------------------------------------------------------------------------------------------------------------+ +|MoveRel | | Move relatively from current the turtle position. Params : 'x, y, z' or 'v'(optionals, default = 0). | ++--------+-----------------------+----------------------------------------------------------------------------------------------------------------------+ +|@2D | StartScreenProjection | The turtle will create geometry in the screen coordinates system. | ++--------+-----------------------+----------------------------------------------------------------------------------------------------------------------+ +|@3D | EndScreenProjection | The turtle will create geometry in the world system (default behaviour). | ++--------+-----------------------+----------------------------------------------------------------------------------------------------------------------+ + +Scale +----- + ++----+-----------+----------------------------------------------------------------------------------------------------------+ +|@Dd | DivScale | Divides the current turtle scale by a scale factor, Params : 'scale_factor' (optional, default = 1.0). | ++----+-----------+----------------------------------------------------------------------------------------------------------+ +|@Di | MultScale | Multiplies the current turtle scale by a scale factor, Params : 'scale_factor' (optional, default = 1.0).| ++----+-----------+----------------------------------------------------------------------------------------------------------+ +|@D | SetScale | Set the current turtle scale, Params : 'scale' (optional, default = 1.0). | ++----+-----------+----------------------------------------------------------------------------------------------------------+ + +Primitive +--------- + ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|F | | Move forward and draw. Params: 'length , topradius'. | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|f | | Move forward and without draw. Params: 'length'. | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|nF | | Produce a n steps path of a given length and varying radius. Params : 'length, dlength [, radius = 1, radiusvariation = None]'. | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|@Gc | StartGC | Start a new generalized cylinder. | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|@Ge | EndGC | Pop generalized cylinder from the stack and render it. | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|{ | BP | Start a new polygon. | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|} | EP | Pop a polygon from the stack and render it. Params : concavetest (default=False). | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|. | PP | Add a point for polygon. | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|LineTo | | Trace line to (x,y,z) without changing the orientation. Params : 'x, y, z, topdiameter' or 'v, topdiameter' (optionals, default = 0). | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|OLineTo | | Trace line toward (x,y,z) and change the orientation. Params : 'x, y, z, topdiameter' or 'v, topdiameter' (optionals, default = 0). | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|LineRel | | Trace line to pos+(x,y,z) without changing the orientation. Params : 'x, y, z, topdiameter' or 'v, topdiameter'(optionals, default = 0). | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|OLineRel | | Trace line toward pos+(x,y,z) and change the orientation. Params : 'x, y, z, topdiameter' or 'v, topdiameter' (optionals, default = 0). | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|@O | Sphere | Draw a sphere. Params : 'radius' (optional, should be positive, default = line width). | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|@B | Box | Draw a box. Params : 'length','topradius'. | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|@b | Quad | Draw a quad. Params : 'length','topradius'. | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|@o | Circle | Draw a circle. Params : 'radius' (optional, should be positive, default = line width). | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|@L | Label | Draw a text label. Params : 'text','size'. | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|surface | | Draw the predefined surface at the turtle's current location and orientation. Params : 'surface_name' (by default, 'l' exists), 'scale_factor' (optional, default= 1.0, should be positive).| ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|~ | | Draw the predefined surface at the turtle's current location and orientation. Params : 'surface_name' (by default, 'l' exists), 'scale_factor' (optional, default= 1.0, should be positive).| ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|@g | PglShape | Draw a geometry at the turtle's current location and orientation. Params : 'geometric_model', 'scale_factor' (optional, should be positive) or 'shape' or 'scene' or 'material'. | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|Frame | | Draw the current turtle frame as 3 arrows (red=heading,blue=up,green=left). Params : 'size' (should be positive), 'cap_heigth_ratio' (in [0,1]), 'cap_radius_ratio' (should be positive). | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|SetContour | | Set Cross Section of Generalized Cylinder. Params : 'Curve2D [, ccw]'. | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|SectionResolution | | Set Resolution of Section of Cylinder. Params : 'resolution' (int). | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|SetGuide | | Set Guide for turtle tracing. Params : 'Curve[2D|3D], length [,yorientation, ccw]'. | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|EndGuide | | End Guide for turtle tracing. | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|Sweep | | Produce a sweep surface. Params : 'path, section, length, dlength [, radius = 1, radiusvariation = None]'. | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|PositionOnGuide | | Set position on Guide for turtle tracing. | ++------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +Width +----- + ++---------+----------+------------------------------------------------------------------------------------------------+ +|_ | IncWidth | Increase the current line width or set it if a parameter is given. Params : 'width' (optional).| ++---------+----------+------------------------------------------------------------------------------------------------+ +|! | DecWidth | Decrease the current line width or set it if a parameter is given. Params : 'width' (optional).| ++---------+----------+------------------------------------------------------------------------------------------------+ +|SetWidth | | Set current line width. Params : 'width'. | ++---------+----------+------------------------------------------------------------------------------------------------+ + +Color +----- + ++------------------+----------+------------------------------------------------------------------------------------------------------------------+ +|; | IncColor | Increase the current material index or set it if a parameter is given. Params : 'index' (optional, positive int).| ++------------------+----------+------------------------------------------------------------------------------------------------------------------+ +|, | DecColor | Decrease the current material index or set it if a parameter is given. Params : 'index' (optional, positive int).| ++------------------+----------+------------------------------------------------------------------------------------------------------------------+ +|SetColor | | Set the current material. Params : 'index' (positive int) or 'r,g,b[,a]' or 'material'. | ++------------------+----------+------------------------------------------------------------------------------------------------------------------+ +|InterpolateColors | | Set the current material. Params : 'index1', 'index2', 'alpha' . | ++------------------+----------+------------------------------------------------------------------------------------------------------------------+ + +Tropism +------- + ++----+------------+------------------------------------------------------------------------------------------------+ +|@Ts | Elasticity | Set Branch Elasticity. Params : 'elasticity' (optional, default= 0.0, should be between [0,1]).| ++----+------------+------------------------------------------------------------------------------------------------+ +|@Tp | Tropism | Set Tropism. Params : 'tropism' (optional, Vector3, default= (1,0,0)). | ++----+------------+------------------------------------------------------------------------------------------------+ + +Request +------- + ++---+----------+------------------------------------------------------------------------------------------------------------+ +|?P | GetPos | Request position vector information. Params : 'x,y,z' or 'v' (optional, default=Vector3, filled by Turtle).| ++---+----------+------------------------------------------------------------------------------------------------------------+ +|?H | GetHead | Request heading vector information. Params : 'x,y,z' or 'v' (optional, default=Vector3, filled by Turtle). | ++---+----------+------------------------------------------------------------------------------------------------------------+ +|?U | GetUp | Request up vector information. Params : 'x,y,z' or 'v' (optional, default=Vector3, filled by Turtle). | ++---+----------+------------------------------------------------------------------------------------------------------------+ +|?L | GetLeft | Request left vector information. Params : 'x,y,z' or 'v' (optional, default=Vector3, filled by Turtle). | ++---+----------+------------------------------------------------------------------------------------------------------------+ +|?R | GetRight | Request right vector information. Params : 'x,y,z' or 'v' (optional, default=Vector3, filled by Turtle). | ++---+----------+------------------------------------------------------------------------------------------------------------+ +|?F | GetFrame | Request turtle frame information. Params : 'p,h,u,l' (optional, filled by Turtle). | ++---+----------+------------------------------------------------------------------------------------------------------------+ + +Texture +------- + ++-----------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|TextureBaseColor | | Set the base color of the texture. Params : 'index' (positive int) or 'r,g,b[,a]' or 'material'. | ++-----------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|InterpolateTextureBaseColors | | Set the base color of the texture from interpolation of 2 predefined material. Params : 'index1', 'index2', 'alpha' . | ++-----------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|TextureScale | | Set the scale coefficient for texture application. Params : 'uscale, vscale' (default = 1,1) or 'scale'. | ++-----------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|TextureUScale | | Set the u-scale coefficient for texture application. Params : 'uscale' (default = 1). | ++-----------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|TextureVScale | TextureVCoeff | Set the v-scale coefficient for texture application. Params : 'vscale' (default = 1). | ++-----------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|TextureTranslation | | Set the translation for texture application. Params : 'utranslation, vtranslation' (default = 0,0) or 'translation'. | ++-----------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|TextureRotation | | Set the rotation for texture application. Params : 'angle, urotcenter, vrotcenter' (default = 0,0.5,0.5) or 'angle, rotcenter'. | ++-----------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|TextureTransformation | | Set the transformation for texture application. Params : 'uscale, vscale, utranslation, vtranslation, angle, urotcenter, vrotcenter' (default = 1,1,0,0,0,0.5,0.5) or 'scale, translation, angle, rotcenter'.| ++-----------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +String Manipulation +------------------- + ++----+-----------+----------------------------------------------------------------------+ +|X | MouseIns | Module inserted just before module selected by user in visualisation.| ++----+-----------+----------------------------------------------------------------------+ +|% | Cut | Cut the remainder of the current branch in the string. | ++----+-----------+----------------------------------------------------------------------+ +|new | newmodule | Create a new module whose name is given by first argument. | ++----+-----------+----------------------------------------------------------------------+ + +Pattern Matching +---------------- + + ++---+-------------+----------------------------------------------------------------------------------------------+ +|=] | | Match exactly a closing bracket | ++---+-------------+----------------------------------------------------------------------------------------------+ +|* | any | Used to match any module in rules predecessor. First argument will become name of the module.| ++---+-------------+----------------------------------------------------------------------------------------------+ +|x | repexp, all | Used to specify matching of a repetition of modules. | ++---+-------------+----------------------------------------------------------------------------------------------+ +|or | || | Used to specify an alternative matching of modules. | ++---+-------------+----------------------------------------------------------------------------------------------+ +|?I | GetIterator | Request an iterator over the current Lstring. | ++---+-------------+----------------------------------------------------------------------------------------------+ +|$ | GetModule | Request a module of the current Lstring. | ++---+-------------+----------------------------------------------------------------------------------------------+ + + + + +Predefined commands +=================== +Here comes the python commands that control the simulation. + +The following commands can be redefined to initialize simulation state: +----------------------------------------------------------------------- + ++---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|def Start([lstring]) |is called at the beginning of the simulation. One argument can be optionally defined to receive the input lstring. A modified lstring can be returned by the function to modify the axiom of the simulation. | ++---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|def End([lstring,geometries]) |is called at the end of the simulation. One or two arguments can be optionally defined to receive the final lstring and its geometric interpretation. A modified lstring or scene can be returned by the function to change output of the simulation. | ++---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|def StartEach([lstring]) |is called before each derivation step. One argument can be optionally defined to receive the input lstring. A modified lstring can be returned by the function to modify input lstring of the current iteration. | ++---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|def EndEach([lstring,geometries])|is called after each derivation step. One or two arguments can be optionally defined to receive the current lstring and its geometric interpretation. Returning an lstring or (lstring, geometries) will be used for next iterations and display. If frameDisplayed() is False, geometries is None.| ++---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|def StartInterpretation() |is called at the beginning of the interpretation. Interpretable modules can be produced to generate extra graphical elements. | ++---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|def EndInterpretation() |is called at the end of the interpretation. Interpretable modules can be produced to generate extra graphical elements. | ++---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|def PostDraw() |is called after drawing the representation of a new lstring. | ++---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +Python commands that control the rule application: +-------------------------------------------------- + ++-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+ +|Stop() |Stop simlation at the end of this iteration. | ++-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+ +|forward() |Next iteration will be done in forward direction. | ++-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+ +|backward() |Next iteration will be done in backward direction. | ++-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+ +|isForward() |Test whether direction is forward. | ++-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+ +|getIterationNb() |Return the id of the current iteration. | ++-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+ +|useGroup(int) |Next iteration will use rules of given group and default group 0. | ++-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+ +|getGroup() |Gives which group will be used. | ++-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+ +|frameDisplay(bool) |Set whether a frame will be displayed at the end of the iteration. default is True in animation and False except for last iteration in run mode.| ++-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+ +|isFrameDisplayed() |Tell whether a frame will be displayed at the end of the iteration. | ++-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+ +|isAnimationEnabled() |Return the current simulation is in an animation. | ++-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+ +|requestSelection(caption)|Wait selection in the viewer before next iteration. Set frameDisplay to True. | ++-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+ + +Lpy specific declaration: +------------------------- + ++--------------------------------+-----------------------------------------------------------------------------+ +|module *name* |Declaration of module name. | ++--------------------------------+-----------------------------------------------------------------------------+ +|consider: *name* |Symbol to consider. | ++--------------------------------+-----------------------------------------------------------------------------+ +|ignore: *name* |Symbol to ignore. | ++--------------------------------+-----------------------------------------------------------------------------+ +|group *id*: |Following rules will be associated to group *id*. | ++--------------------------------+-----------------------------------------------------------------------------+ +|Axiom: *Lstring* |Declaration of the axiom of the Lsystem. | ++--------------------------------+-----------------------------------------------------------------------------+ +|produce *Lstring* |Produce an *Lstring* and return. | ++--------------------------------+-----------------------------------------------------------------------------+ +|nproduce *Lstring* |Produce an *Lstring* whithout returning. | ++--------------------------------+-----------------------------------------------------------------------------+ +|nsproduce(*LstringStruct*) |Produce a given *Lstring* data structure whithout returning. | ++--------------------------------+-----------------------------------------------------------------------------+ +|makestring(*Lstring*) |Create an *LstringStruct* from *Lstring*. | ++--------------------------------+-----------------------------------------------------------------------------+ +|InLeftContext(pattern, argdict) |Test a left context. argdict contains value of all parameter of the pattern. | ++--------------------------------+-----------------------------------------------------------------------------+ +|InRightContext(pattern, argdict)|Test a right context. argdict contains value of all parameter of the pattern.| ++--------------------------------+-----------------------------------------------------------------------------+ +|derivation length: *value* |Number of derivation to do (default=1). | ++--------------------------------+-----------------------------------------------------------------------------+ +|initial_view=*value* |Number of derivation for bounding box evaluation (default=derivation length).| ++--------------------------------+-----------------------------------------------------------------------------+ +|production: |Start of the production rules declaration. | ++--------------------------------+-----------------------------------------------------------------------------+ +|homomorphism: |Start of the interpretation rules declaration. | ++--------------------------------+-----------------------------------------------------------------------------+ +|interpretation: |Start of the interpretation rules declaration. | ++--------------------------------+-----------------------------------------------------------------------------+ +|decomposition: |Start of the decomposition rules declaration. | ++--------------------------------+-----------------------------------------------------------------------------+ +|maximum depth: |Number of decomposition or interpretation recursive call to do (default=1). | ++--------------------------------+-----------------------------------------------------------------------------+ +|endgroup |Reactivate default group 0. | ++--------------------------------+-----------------------------------------------------------------------------+ +|endlsystem |End of lsystem rules declaration. | ++--------------------------------+-----------------------------------------------------------------------------+ + +These commands have been added to the original cpfg-lpfg specification: +----------------------------------------------------------------------- + ++---------+-----------------------------------------------------------+ +|context()|Get context of execution of the L-system. To use with care.| ++---------+-----------------------------------------------------------+ + +The following objects and commands are also accessible from within the lpy shell: +--------------------------------------------------------------------------------- + ++-------+-----------------------------------------------------------------------------+ +|lstring|Contains the last computed lsystem string of the current simulation. | ++-------+-----------------------------------------------------------------------------+ +|lsystem|Reference to the internal lsystem object representing the current simulation.| ++-------+-----------------------------------------------------------------------------+ +|window |Reference to lpy widget object. | ++-------+-----------------------------------------------------------------------------+ +|clear()|To clear the shell. | ++-------+-----------------------------------------------------------------------------+ +All these functions are imported from openalea.lpy module. Other data structures and functionnalities are available in the module. You can check them with **help(openalea.lpy)** + +References +========== +For More details, see: + +- F. Boudon, T. Cokelaer, C. Pradal and C. Godin, L-Py, an open L-systems framework in Python, FSPM 2010. +- P. Prusinkiewicz et al., 89, The algorithmic Beauty of Plants, Springer-Verlag. +- P. Prusinkiewicz. Graphical applications of L-systems. Proceedings of Graphics Interface '86, pp. 247-253. +- P. Prusinkiewicz, R. Karwowski, and B. Lane. The L+C plant modelling language. In Functional-Structural Plant Modelling in Crop Production, J. Vos et al. (eds.), Springer, 2007. diff --git a/doc/user/installing.rst b/doc/user/installing.rst index c1bd8df4..4cea343d 100644 --- a/doc/user/installing.rst +++ b/doc/user/installing.rst @@ -20,7 +20,7 @@ All these projects have to be correctly installed before compiling ``L-Py``. Additionally, the ``Cython`` module that make it possible to translate python code into ``C`` code is automatically integrated to the project if detected. You can install it if you want to test this extension. Installing for Linux & Mac -=================== +========================== First, you need to install conda: https://conda.io/docs/user-guide/install/index.html @@ -43,7 +43,7 @@ And run L-Py lpy Installing binaries (Windows) -=================== +============================= You can download binaries of this project via the OpenAlea Installer after loggin on the Inria Gforge. diff --git a/doc/user/turtle.rst b/doc/user/turtle.rst deleted file mode 100644 index a07f3fc8..00000000 --- a/doc/user/turtle.rst +++ /dev/null @@ -1,248 +0,0 @@ -L-Py Turtle explanation -####################### - -Initial orientation of turtle’s frame -===================================== - -Global reference frame (X,Y,Z) of L-Py (A). - -The Turtle reference frame (H,L,U) is defined in (B) and can be displayed using primitive **Frame** - -.. code-block:: python - - Axiom: Frame - -.. image:: ../_images/ex001.png - -Visualize the turtle reference frame -==================================== - -Default angle is 60° ( **+** is identical to **+(60)** ) - -.. code-block:: python - - Axiom: FF[+ FF]FFF # Original code (A) - - Axiom: Frame FF[+ FF Frame ]F Frame FF # New code with Frames (B) - -.. image:: ../_images/ex002.png - -Rotating with HLU -================= - -Primitives can be used to rotate the turtle in its current reference frame (H = Head, L = Left, U = Up, angles are expressed by default in degrees). - -.. code-block:: python - - Axiom: Frame /(60) Frame # Around turtle's Head - - Axiom: Frame ^(60) Frame # Around turtle's Left arm (note that the rotation is indirect) - - Axiom: Frame +(60) Frame # Around turtle's Up side - -.. image:: ../_images/ex003.png - -Drawing Polygons -================ - -Basic method ------------- - -Turn and move forward - -.. code-block:: python - - Axiom: Frame(2)+(30)F(5)+(120)F(5)+(120)F(5) # (A) - -Procedural method ------------------ - -A loop construct can be used to produce the L-string specifying the polygon - -.. code-block:: python - - Axiom: Frame(2)+F(5)+F(5)+F(5)+F(5)+F(5)+F(5) # (B) - # Or equivalently: - Axiom: - nproduce Frame(2) - for i in range(6): - nproduce +F(5) - -.. image:: ../_images/ex004.png - -Filled polygon -============== - -Polygon can be drawn by using {} and positioning a series of dots ('.') in space, corresponding to the consecutive vertices of the polygon (A) - -Here, the instruction starts by positioning the first vertex of the polygon at the origin of the reference frame - -.. code-block:: python - - Axiom: _(0.05),(2){.f(3).-(90)f(3).-(90)f(3).-(90)f(3)} - -The contour of the polygon can be drawn by using **F** instead of **f**. In this case, dots (.) are no longer required after each **F** (B) - -.. code-block:: python - - Axiom: _(0.05),(2){.F(3)-(90)F(3)-(90)F(3)-(90)F(3)} - -The number of edges drawn can be different from the number of vertices (C) - -.. code-block:: python - - Axiom: _(0.05),(2){.F(3)-(90)F(3)-(90)F(3)} - -Note that if the first dot/point is omitted, the polygon is not closed (D) - -.. code-block:: python - - Axiom: _(0.05),(2){F(3)-(90)F(3)-(90)F(3)} - -.. image:: ../_images/ex005.png - :scale: 70% - -Filling concave objects requires to use a smarter filling procedure. This can be acheived by using a **True** argument to the polygon drawing (by default the argument is **False**) - -.. code-block:: python - - # Naive procedure to fill the concave form: (A) - Axiom: _(0.01),(2) {.F+(95)F(0.7)-(120)F(0.2)+(80)F-(120)F(0.2)+(80)F(0.5) - -(120)F(0.5)+(80)F(0.2)-(120)F(0.5)+(150)F-(120)F(0.3)+(80)F -(120)F+(80)F(0.3) - -(120)F +(150)F(0.5)-(120)F(0.2)+(80)F(0.5)-(120)F(0.5)+(80)F(0.2)-(120)F+(120)F(0.2) - -(150)F(0.7)+(95)F}(False) - # while with a smarter procedure: (B) - Axiom: _(0.01),(2) {.F+(95)F(0.7)-(120)F(0.2)+(80)F-(120)F(0.2)+(80)F(0.5) - -(120)F(0.5)+(80)F(0.2)-(120)F(0.5)+(150)F-(120)F(0.3)+(80)F -(120)F+(80)F(0.3) - -(120)F +(150)F(0.5)-(120)F(0.2)+(80)F(0.5)-(120)F(0.5)+(80)F(0.2)-(120)F+(120)F(0.2) - -(150)F(0.7)+(95)F}(True) - -.. image:: ../_images/ex006.png - -Branching system -================ - -Bracket makes it possible to specify branches. Before each opening bracket, the turtle parameters (represented by the Frames) are stored on the Turtle stack. These parameters are then pop back when a closing bracket is found. - -.. code-block:: python - - Axiom: F(2) [+F[-F(0.5)]F(0.5)] F [-F] F - -The same branching system can be augmented with other modules (@**O** for sphere, ...) - -.. code-block:: python - - Axiom: F(2) [+F[-F(0.5);(3)@O(0.2)]F(0.5);(3)@O(0.2)] F[-F;(3)@O(0.2)] F;(3)@O(0.2) - -.. image:: ../_images/ex007.png - :scale: 50% - -SetGuide -======== - -Drawing a straight line made of length **l=10** with segments of size **dl = 1.0** (and thus contains n= 10 segments) (A) - -.. code-block:: python - - Axiom: nF(10, 1.) - -By adding the primitive SetGuide before the line drawing, it is possible to specify a curve on which the turtle is moving (instead of heading straight). - - -The **SetGuide** primitive must be given two mandatory arguments: a curve (Polyline2D or NurbsCurve2D) and a length: **SetGuide(C0, L0)**. This means that, following this statement, the turtle will move on curve **C1** that has been rescaled from **C0** so that its new length is **L0** (whatever its original length). - -The guiding curve can be defined in different ways. It can be defined for example by a python function (**function f** defined hereafter), e.g. (B) : - -.. code-block:: python - - from openalea.plantgl.all import Polyline2D - from numpy import arange - - def f(u): - return (u,u**2) - - C0 = Polyline2D([f(u) for u in arange(0,1,0.1)]) # (B) - -or using the embedded L-Py graphical interface for specifying 2D curves (the curve is then given the name **C0** for instance in the interface): - -.. image:: ../_images/ex009.png - :scale: 70% - -Then using curve **C0** in the **SetGuide** primitive, one can move the turtle over a cumulated length **L**, thus using the defined curve **C1** (rescaled from **C0**) as a guide for moving up to a total length **L0** (C): - -.. code-block:: python - - L = 10 - L0 = 10 - Axiom: SetGuide(C0,L0) nF(L, 0.1) - -.. image:: ../_images/ex008.png - :scale: 60% - -Note that the turtle can move less than the length of the 2D curve. In this case it will proceed forward over the **L** first units at the beginning of curve **C1** (B). By contrast, if **L** > **L0**, then the turtle keeps on moving straight after reaching length **L0** (C). - -.. code-block:: python - - L = 6 - L0 = 10 - Axiom: SetGuide(C0,L0) nF(L, 0.1) # (B) - - L = 15 - L0 = 10 - Axiom: SetGuide(C0,L0) nF(L, 0.1) # (C) - -.. image:: ../_images/ex010.png - :scale: 60% - -.. _turtle_color_system: - -Color System -============ - -To use color system, it is necessary to set materials with the **Color Map** window (:ref:`Editor_Color_Map`). - -The semicolon (';') is use to increase the current material index (A) and the comma (',') to dricrease it (B). -A parameter can be set to specify the index of the material to use. - -.. code-block:: python - - Axiom: F(2) ; @O(0.2) # (A) - # Or equivalently: - Axiom: F(2) ;(2) @O(0.2) - - Axiom: F(2) , @O(0.2) # (B) - # Or equivalently: - Axiom: F(2) ,(0) @O(0.2) - -.. image:: ../_images/ex011.png - :scale: 60% - -The second manner to set color to an object is to use **SetColor**. There is two way to use it. -The first way is to specify the index of the material (A) and the second way is to set the **rgb** (or rgba) values in parameters (B). - -.. code-block:: python - - Axiom: F(2) SetColor(5) @O(0.2) # (A) - - Axiom: F(2) SetColor(45, 200, 200) @O(0.2) # (B) - -.. image:: ../_images/ex012.png - :scale: 60% - -The last manner to use the color system is to use **InterpolateColors**, it use to mix up two colors in one. -There is three parameter, the first and the second are the index of materials and the last is optional and it use to set a priority to the first or the second color to make the final color. - -.. code-block:: python - - Step = 20 - DIncr = 1.0 / Step - - Axiom: - d = 0.0 - for i in range(Step): - nproduce InterpolateColors(3, 5, d) F(0.1) - d += DIncr - produce ;(2) @O(0.15) - -.. image:: ../_images/ex013.png - :scale: 60% \ No newline at end of file diff --git a/doc/user/turtleAdvanced.rst b/doc/user/turtleAdvanced.rst new file mode 100644 index 00000000..3e20b291 --- /dev/null +++ b/doc/user/turtleAdvanced.rst @@ -0,0 +1,168 @@ +L-Py Turtle advanced primitives +############################### + +Using PlantGL primitives +~~~~~~~~~~~~~~~~~~~~~~~~ + +Drawing PlantGL shapes +====================== + +In order to draw more complex but predifined shapes, certain methods use PlantGL primitives These methods are **~** and **@g**. +**@g** draws the PlantGL shape in argument. **~** is more complicated, it takes in argument a geometric shape saved in the Turtle. +A special primitive is already predifined : **~l**. It draws a leaf. + +.. code-block:: python + + Axiom: ~l #(Fig. A) + + Axiom: @g(Sphere(radius=3)) #(Fig. B) + + execContext().turtle.setSurface('t',Sphere(radius=3)) + Axiom: ~t(5) #(Fig. C) + ++--------------------------------+--------------------------------+--------------------------------+ +| .. image:: ../_images/leaf.png | | | ++--------------------------------+--------------------------------+--------------------------------+ + +Miscellaneous +~~~~~~~~~~~~~ + +In this section, several less common tools can be found. + +Elasticity and Tropism +====================== + +One can add an elasticity property to a branch using **@Ts** or **Elasticity**. The value in argument should be between 0. and 1. + +.. code-block:: python + + Axiom: FF[Elasticity(0.5)+F+F]F[-F]F #(Fig. A) + +A particular tropism can be setted using **@Tp** or **Tropism**. It takes a vector in argument. + +.. code-block:: python + + import numpy as np + v = np.array([0,1,2]) + Axiom: FF[Tropism(v)+F+F]F[-F]F #(Fig. B) + + +SectionResolution +================= + +**SectionResolution** allows to change the resolution of all following shapes. **Be careful !** If the resolution is too low, the program may not work properly. + +.. code-block:: python + + Axiom: F SectionResolution(4) +F@O(0.5) #(Fig. A) + + Axiom: F SectionResolution(60) +F@O(0.5) #(Fig. B) + +Download the example : :download:`resolution.lpy <../_downloads/resolution.lpy>` + ++---------------------------------------+---------------------------------------+ +| .. image:: ../_images/resolution1.png | .. image:: ../_images/resolution2.png | +| :scale: 60% | :scale: 60% | ++---------------------------------------+---------------------------------------+ + +ScreenProjection +================= + +After using **@2D** (or **StartScreenProjection**), the following shapes will be drawn on the screen coordinates system (in two dimensions). +The examples below belong to the same axiom, only the camera's orientation is different. It confirms that the shape is in the screen system. + +.. code-block:: python + + Axiom: Frame @2DF(0.6)@O(0.2) + +Download the example : :download:`screen.lpy <../_downloads/screen.lpy>` + ++-------------------------------+-------------------------------+ +| .. image:: ../_images/2D1.png | .. image:: ../_images/2D2.png | +| :scale: 70% | :scale: 70% | ++-------------------------------+-------------------------------+ + +To switch back to the original coordinates system, **@3D** (or **EndScreenProjection**) can be used. + +InterpolateColors +================= + +There is an other way to color shapes using **InterpolateColors**. This method mixes up two colors in one. +There are three arguments, the first and the second are the index of materials and the last (optional) sets a priority to the first or the second color in order to make the final color. +There are two examples below. + +.. code-block:: python + + Step = 20 + DIncr = 1.0 / Step + + Axiom: + d = 0.0 + for i in range(Step): + nproduce InterpolateColors(3, 5, d) F(2.0/Step) #(Fig. A) + d += DIncr + produce ;(2) @O(0.15) + + #Other example + + Step = 4 + DIncr = 1.0 / Step + + Axiom: + d = 0.0 + for i in range(Step): + nproduce InterpolateColors(2, 5, d) F(2.0/Step) #(Fig. B) + d += DIncr + produce ;(1) @O(0.15) + +Download the example : :download:`InterpolateColors.lpy <../_downloads/InterpolateColors.lpy>` + ++---------------------------------------------+----------------------------------------------+ +| .. image:: ../_images/interpolateColors.png | .. image:: ../_images/interpolateColors2.png | +| :scale: 50% | :scale: 50% | ++---------------------------------------------+----------------------------------------------+ + +Advanced rotation primitives +============================ + +There are other primitives that can be used to rotate the Turtle. + +**TurnAround** or **|**, turn the Turtle for 180° around the Up vector. It produce the same result as **+(180)** or **(-180)** + +.. code-block:: python + + Axiom: Frame(2) | Frame(2) + ++--------------------------------------+ +| .. image:: ../_images/turnAround.png | ++--------------------------------------+ + +Requests +======== + +These methods allow to get some informations about the Turtle and store it in variables in order to use it after. Except **GetFrame**, +it all can take three floats or one vector in arguments. If done, arguments are filled with values requested. + +- **GetPos** or **?P**, collect the Turtle's Position vector informations. + +- **GetHead** or **?H**, collect the Turtle's Head vector informations. + +- **GetUp** or **?U**, collect the Turtle's Head vector informations. + +- **GetLeft** or **?L**, collect the Turtle's Left vector informations. + +- **GetRight** or **?R**, collect the Turtle's Right vector informations. + +**GetFrame** or **?F**, collect the Turtle's Frame vector informations. +It can take four vectors in arguments and fill it with the Position vector, the Head vector, the Up vector and the Left vector. + +Rewriting shapes +~~~~~~~~~~~~~~~~ + +To clear the viewer, the primitive **None** can be written in the Axiom part. + +.. code-block:: python + + Axiom: None + +*Work in progress* diff --git a/doc/user/turtleBasic.rst b/doc/user/turtleBasic.rst new file mode 100644 index 00000000..0d8d32d2 --- /dev/null +++ b/doc/user/turtleBasic.rst @@ -0,0 +1,757 @@ +L-Py Turtle basic primitives +############################ + +There is the list of the primitives explained in this page : + +.. csv-table:: Table of primitives + + F_, width_ (!), rotation_ (/), MoveTo_, nF_ + f_, color_ (;), rotation_ (\\), MoveRel_, LineTo_ + @\ O_, color_ (;), rotation_ (^), Pinpoint_, LineRel_ + @\ o_, setColor_, rotation_ (&), PinpointRel_, OLineTo_ + @\ B_, branching_ ([]), rotation_ (\+), setHead_ (@R), OLineRel_ + @\ b_, polygons_ (.), rotation_ (\-), EulerAngles_, SetGuide_ + width_ (_), Frame_ , Rescaling_, , generalisedCylinders_ (@Gc and @Ge) + +Constructing basic shapes with the Turtle +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Simple Turtle instructions +========================== + +The Turtle is a geometric tool defined by a reference frame (usually not visible) that can be moved using geometric instructions. + +.. code-block:: python + + #Turtle initial position (Fig. A) + Axiom: F #(Fig. B) + Axiom: FFF #(Fig. C) + Axiom: F+F+F #(Fig. D) + ++------------------------------------+-----------------------------------+ +| .. image:: ../_images/turtle1.png | .. image:: ../_images/turtle2.png | +| :scale: 40% | :scale: 40% | ++------------------------------------+-----------------------------------+ +| .. image:: ../_images/turtle3.png | .. image:: ../_images/turtle4.png | +| :scale: 40% | :scale: 40% | ++------------------------------------+-----------------------------------+ + +In this way, different types of shapes can be constructed : + +.. code-block:: python + + Axiom: F+F-F #(Fig. A) + Axiom: FF-(90)FF-(90)FF-(90)FF #(Fig. B) + Axiom: FF[-F][+F]F #(Fig. C) + + + ++-------------------------------+----------------------------------+----------------------------------+ +| .. image:: ../_images/F-.png | .. image:: ../_images/square.png | .. image:: ../_images/branch.png | +| :scale: 40% | :scale: 40% | :scale: 40% | ++-------------------------------+----------------------------------+----------------------------------+ + +.. _F: + +To resume, the **F** primitive moves the Turtle and draws a cylinder of one unit. + +To move the Turtle without drawing something, **f** should be used. The argument defines the number of steps the Turtle will move. + +.. code-block:: python + + Axiom: F[+fF]F[-fF]FF #(Fig. A) + + Axiom: +(90)F-(45)f-(45)F-(45)f-(45)F-(45)f-(45)F #(Fig. B) + ++-----------------------------+-------------------------------+ +| .. image:: ../_images/f.png | .. image:: ../_images/f2.png | +| :scale: 60% | :scale: 60% | ++-----------------------------+-------------------------------+ + +Other basic geometric primitives make it possible to draw other predifined shapes : + +.. _O: + +.. _B: + +.. code-block:: python + + Axiom: @O(1) # Draws a sphere at the Turtle's position. + # It can take one argument which is the radius of the sphere. + + Axiom: @o(1) # Draws a circle at the Turtle's position. + # It can take one argument which is the radius of the circle. + + Axiom: @B(1) # Draws a box at the Turtle's position. + # It can take two arguments which are the length of the edges and the topradius. + + Axiom: @b(1) # Draws a quad at the Turtle's position. + # It can take two arguments which are the length of the edges and the topradius. + ++----------------------------------+----------------------------------+ +| .. image:: ../_images/sphere.png | .. image:: ../_images/circle.png | ++----------------------------------+----------------------------------+ +|.. image:: ../_images/box.png | .. image:: ../_images/quad.png | ++----------------------------------+----------------------------------+ + +**F** can take one or two arguments (of type float). If only one argument is given, it defines the length of the cylinder drawn (default value = 1). The diameter is by set by default to 0.1. + +.. code-block:: python + + Axiom: F(3) #(Fig. A) + +If a second argument is given, it redefines the topradius of the cylinder (but the bottom radius is defined by the value of radius in the current Turtle state) + +.. code-block:: python + + Axiom: F(3, 2.5) #(Fig. B) + +To change the value of the Turtle's radius before applying the F command, one can use the **_** command: + +.. code-block:: python + + Axiom: _(2.5)F(3, 2.5) #(Fig. C) + ++------------------------------+--------------------------------+------------------------------+ +| .. image:: ../_images/F3.png | .. image:: ../_images/F2,5.png | .. image:: ../_images/_F.png | +| :scale: 40% | :scale: 40% | :scale: 40% | ++------------------------------+--------------------------------+------------------------------+ + +Text can be displayed using the **@L** primitive but it doesn't appear on screenshots + +.. code-block:: python + + Axiom: @L("Some text", 18) # Draws a text Label at the Turtle's position. + # It can take two arguments which are the text to display and it's size. + +Some useful tools +================= + +*Changing the width* +-------------------- + +.. _width: + +The width of the shapes can be increased (resp. decreased) using **_** (resp. **!**). These primitives increment or decrement width by 1. The default width is 0.1. + +.. code-block:: python + + Axiom: F_ _ _F!F!F #At the beginning, the cylinder has a width of 0.1 (default) then 3.1, then 2.1 and finally 1.1 (Fig. A) + ++---------------------------------+----------------------------------+ +| .. image:: ../_images/width.png | .. image:: ../_images/width2.png | +| :scale: 60% | :scale: 60% | ++---------------------------------+----------------------------------+ + +Alternatively, the width can be set using **setWidth** or by giving argument to **_** or **!** + +.. code-block:: python + + Axiom: F_(2)F!(3)F!(1)F #(Fig. B) + +Download the example : :download:`width.lpy <../_downloads/width.lpy>` + + +*Color System* +-------------- + +.. _color: + +To use color system, it is necessary to set materials with the **Color Map** window (:ref:`Editor_Color_Map`). + +The semicolon (';') is used to increase the current material index (Fig. A) and the comma (',') to decrease it (Fig. B). +A argument can be set to specify the index of the material to use. + +.. code-block:: python + + Axiom: F(2) ; @O(0.2) # (Fig. A) + # Or equivalently: + Axiom: F(2) ;(2) @O(0.2) + + Axiom: F(2) , @O(0.2) # (Fig. B) + # Or equivalently: + Axiom: F(2) ,(0) @O(0.2) + ++------------------------------------------+------------------------------------------+ +| .. image:: ../_images/increase_color.png | .. image:: ../_images/decrease_color.png | +| :scale: 50% | :scale: 50% | ++------------------------------------------+------------------------------------------+ + +.. _setColor: + +The second manner to set color to an object is to use **SetColor**. There is two way to use it. +The first way is to specify the index of the material (Fig. A) and the second way is to set the **rgb** (or rgba) values in arguments (Fig. B). + +.. code-block:: python + + Axiom: F(2) SetColor(5) @O(0.2) # (Fig. A) + + Axiom: F(2) SetColor(45, 200, 200) @O(0.2) # (Fig. B) + ++-------------------------------------+-------------------------------------+ +| .. image:: ../_images/setColor1.png | .. image:: ../_images/setColor2.png | +| :scale: 50% | :scale: 50% | ++-------------------------------------+-------------------------------------+ + +Primitive combinations +====================== + +All these primitives can be combined together (**~l** draws a leaf). There are two examples : + +.. code-block:: python + + Axiom: F[;+~l]F[;-~l]F[;+~l]F[;-~l]F[;+~l]F[;-~l]F #(Fig. A) + + Axiom: ;@B(5),@O(0.5)_(0.5)F(3,0.5)_(0.2)@O(0.5) #(Fig. B) + +Download the example : :download:`combined.lpy <../_downloads/combined.lpy>` + ++------------------------------------+-------------------------------------+ +| .. image:: ../_images/combined.png | .. image:: ../_images/combined2.png | +| :scale: 40% | :scale: 40% | ++------------------------------------+-------------------------------------+ + +Drawing more complex shapes +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +In order to draw complex shapes, some basic knowledge about the Turtle is required. + +Definition of the Turtle’s reference frame (HLU) +================================================ +.. OK + +.. _Frame: + +In L-Py, screen coordinates are defined in a global reference frame F0 = (X,Y,Z) of L-Py (Fig. A). + +The Turtle is defined by a reference frame (H,L,U) with respect to F0 (Fig. B) and can be displayed using the primitive **Frame** + +- H (Head) pointing in the direction of the Turtle's "head". +- L (Left) pointing in the direction of the Turtle's "left arm". +- U (Up) pointing in the direction of for the Turtle's back ("up"). + +.. code-block:: python + + Axiom: Frame + ++--------------------------------+---------------------------------+ +| .. image:: ../_images/axis.png | .. image:: ../_images/frame.png | +| :scale: 100% | :scale: 100% | ++--------------------------------+---------------------------------+ + +Rotating with HLU (Main primitives) +=================================== + +.. _rotation: + +Primitives can be used to rotate the Turtle in its current reference frame (H = Head, L = Left, U = Up, angles are expressed by default in degrees). +These primitives are paired (one and it's opposite) : **/** and **\\**, **^** and **&** and finally **+** and **-**. + +.. code-block:: python + + Axiom: Frame(2) /(60) Frame(2) # Roll left arround the H axis. (Fig. A) + + Axiom: Frame(2) \(60) Frame(2) # Roll right arround the H axis. (Fig. B) + + Axiom: Frame(2) ^(60) Frame(2) # Pitch up arround the L axis. (note that the rotation is indirect) (Fig. C) + + Axiom: Frame(2) &(60) Frame(2) # Pitch down arround the L axis. (note that the rotation is indirect) (Fig. D) + + Axiom: Frame(2) +(60) Frame(2) # Turn left arround the U axis. (Fig. E) + + Axiom: Frame(2) -(60) Frame(2) # Turn right arround the U axis. (Fig. F) + +Download the example : :download:`rotation.lpy <../_downloads/rotation.lpy>` + ++-------------------------------------+-------------------------------------+-------------------------------------+ +| .. image:: ../_images/rotation1.png | .. image:: ../_images/rotation3.png | .. image:: ../_images/rotation5.png | +| :scale: 40% | :scale: 40% | :scale: 40% | ++-------------------------------------+-------------------------------------+-------------------------------------+ +| .. image:: ../_images/rotation2.png | .. image:: ../_images/rotation4.png | .. image:: ../_images/rotation6.png | +| :scale: 40% | :scale: 40% | :scale: 40% | ++-------------------------------------+-------------------------------------+-------------------------------------+ + +Rescaling the Turtle +==================== +.. OK + +.. _Rescaling: + +Three primitives can be used to rescale the Turtle : **SetScale**, **DivScale** and **MultScale** (shorter symbols are **@D**, **@Di** and **@D** respectively) +**SetScale** sets the scale to the value in argument. **DivScale** (resp. **MultScale**) divides (resp. multiplies) the current scale by the value given in argument. +The first image is the initial shape (Fig. A) and the second one is the same shape where the branches are rescaled (Fig. B). + +.. code-block:: python + + Axiom: FF[-F[-F]F]FF #(Fig. A) + + Axiom: @D(2)FF[@Dd(1.5)-F[@Di(0.5)-F]F]FF #(Fig. B) + +Download the example : :download:`scale.lpy <../_downloads/scale.lpy>` + ++----------------------------------------+-------------------------------------+ +| .. image:: ../_images/initialScale.png | .. image:: ../_images/rescaling.png | ++----------------------------------------+-------------------------------------+ + +How to draw polygonal shapes ? +============================== + +*Basic method* +-------------- + +Turn and move forward : Here, at each **+**, the Turtle does a rotation of the number of degrees indicated in arguments arround the U axis + +.. code-block:: python + + Axiom: Frame(2)+(30)F(5)+(120)F(5)+(120)F(5) # (Fig. A) + +Download the example : :download:`polygons.lpy <../_downloads/polygons.lpy>` + +*Procedural method* +------------------- + +A loop construct can be used to produce the L-string specifying the polygon + +.. code-block:: python + + Axiom: Frame(2)+F(5)+F(5)+F(5)+F(5)+F(5)+F(5) # (Fig. B) + # Or equivalently: + Axiom: + nproduce Frame(2) + for i in range(6): + nproduce +F(5) + ++----------------------------------------+---------------------------------------+ +| .. image:: ../_images/basicPolygon.png | .. image:: ../_images/loopPolygon.png | +| :scale: 50% | :scale: 50% | ++----------------------------------------+---------------------------------------+ + +*Filled polygons* +----------------- + +.. _polygons: + +Polygon can be drawn by using {} and positioning a series of dots ('.') in space, corresponding to the consecutive vertices of the polygon (Fig. A) + +Here, the instruction starts by positioning the first vertex of the polygon at the origin of the reference frame + +.. code-block:: python + + Axiom: Frame _(0.05),(2){.f(3).-(90)f(3).-(90)f(3).-(90)f(3)} + +The contour of the polygon can be drawn by using **F** instead of **f**. In this case, dots (.) are no longer required after each **F** (Fig. B) + +.. code-block:: python + + Axiom: Frame _(0.05),(2){.F(3)-(90)F(3)-(90)F(3)-(90)F(3)} + +The number of edges drawn can be different from the number of vertices (Fig. C) + +.. code-block:: python + + Axiom: Frame _(0.05),(2){.F(3)-(90)F(3)-(90)F(3)} + +Note that if the first dot/point is omitted, the polygon is not closed (Fig. D) + +.. code-block:: python + + Axiom: Frame _(0.05),(2){F(3)-(90)F(3)-(90)F(3)} + +Download the example : :download:`filledPolygons.lpy <../_downloads/filledPolygons.lpy>` + ++------------------------------------------+------------------------------------------+ +| .. image:: ../_images/filledPolygon1.png | .. image:: ../_images/filledPolygon2.png | ++------------------------------------------+------------------------------------------+ +| .. image:: ../_images/filledPolygon3.png | .. image:: ../_images/filledPolygon4.png | ++------------------------------------------+------------------------------------------+ + +Filling concave objects requires to use a smarter filling procedure. This can be acheived by using a **True** argument to the polygon drawing (by default the argument is **False**) + +.. code-block:: python + + # Naive procedure to fill the concave form: (Fig. A) + Axiom: _(0.01),(2) {.F+(95)F(0.7)-(120)F(0.2)+(80)F-(120)F(0.2)+(80)F(0.5) + -(120)F(0.5)+(80)F(0.2)-(120)F(0.5)+(150)F-(120)F(0.3)+(80)F -(120)F+(80)F(0.3) + -(120)F +(150)F(0.5)-(120)F(0.2)+(80)F(0.5)-(120)F(0.5)+(80)F(0.2)-(120)F+(120)F(0.2) + -(150)F(0.7)+(95)F}(False) + # while with a smarter procedure: (Fig. B) + Axiom: _(0.01),(2) {.F+(95)F(0.7)-(120)F(0.2)+(80)F-(120)F(0.2)+(80)F(0.5) + -(120)F(0.5)+(80)F(0.2)-(120)F(0.5)+(150)F-(120)F(0.3)+(80)F -(120)F+(80)F(0.3) + -(120)F +(150)F(0.5)-(120)F(0.2)+(80)F(0.5)-(120)F(0.5)+(80)F(0.2)-(120)F+(120)F(0.2) + -(150)F(0.7)+(95)F}(True) + ++---------------------------------+---------------------------------+ +| .. image:: ../_images/leaf1.png | .. image:: ../_images/leaf2.png | +| :scale: 50% | :scale: 50% | ++---------------------------------+---------------------------------+ + +Branching system +================ + +.. _branching: + +Bracket makes it possible to specify branches. Before each opening bracket, the Turtle current arguments (position, orientation...) are stored on the Turtle stack. These arguments are then popped back when a closing bracket is found and the drawing restarts from the popped values. + +.. code-block:: python + + Axiom: F(4)[+F(3)]F(4) #(Fig. A) + +Then it's possible to nest branches inside each others : + +.. code-block:: python + + Axiom: F(4)[+F(2)[+F(1)]F(1)]F(3)[-F(1)]F(1) #(Fig. B) + +Download the example : :download:`branching.lpy <../_downloads/branching.lpy>` + ++--------------------------------------+--------------------------------------+ +| .. image:: ../_images/branching1.png | .. image:: ../_images/branching2.png | +| :scale: 40% | :scale: 40% | ++--------------------------------------+--------------------------------------+ + +.. code-block:: python + + Axiom: Frame F(4)[+F(2)[+F(1)Frame]F(1)]FrameF(3)[-F(1)]F(1) # New code with Frames (Fig. C) + ++--------------------------------------+--------------------------------------+ +| .. image:: ../_images/with_frame.png | .. image:: ../_images/branching3.png | +| :scale: 40% | :scale: 40% | ++--------------------------------------+--------------------------------------+ + +The same branching system can be augmented with other modules (**Frame**, **@O**, **@B**,...) (Fig. D) + +.. code-block:: python + + Axiom: F(4)[+F(2)[+F(1);(3)@O(0.2)]F(1);(3)@O(0.2)]F(3)[-F(1);(3)@O(0.2)]F(1);(3)@O(0.2) #(Fig. D) + +A more complex combined shape +============================= + +There is below a more complex shape using the previous primitives. In this example, **~l** is used. This primitive draws a leaf. + +.. code-block:: python + + Axiom: F[;-(70)f(0.1)\(80)~l]F[;+(70)f(0.1)/(80)~l][-F[;+(70)f(0.1)~l][F(1.2);@O(0.2)]-F(0.6)[-f(0.4);(3)@O(0.3)]F(0.6);@O(0.2)] + F(1.5)[;+(70)f(0.1)/(70)~l]F(0.1)[+F;@O(0.2)]F;@O(0.2) + +Download the example : :download:`harderExample.lpy <../_downloads/harderExample.lpy>` + ++-----------------------------------------+ +| .. image:: ../_images/harderExample.png | ++-----------------------------------------+ + +Advanced primitives +=================== + +Moving the Turtle +================= + +There are some primitives which can be used to change the Turtle's position. + +*MoveTo and MoveRel* +-------------------- + +.. _MoveTo: + +**@M** (or **MoveTo**) moves the Turtle's to the given in arguments. It can be three floats or a vector. + +.. code-block:: python + + Axiom: @M(0,2,0) Frame #(Fig. A) + + import numpy as np + v = np.array([0,1,1]) + Axiom: MoveTo(v) #(Fig. B) + +Download the example : :download:`movement.lpy <../_downloads/movement.lpy>` + ++---------------------------------------+---------------------------------------+ +| .. image:: ../_images/moveTo1.png | .. image:: ../_images/moveTo2.png | +| :scale: 60% | :scale: 60% | ++---------------------------------------+---------------------------------------+ + +.. _MoveRel: + +**MoveRel** works almost in the same way but it moves the Turtle relatively to the current position : + +.. code-block:: python + + Axiom: F MoveTo(0,3,0) Frame #The Turtle moves to the position (0,3,0) (Fig. A) + + Axiom: F MoveRel(0,3,0) Frame #The Turtle moves along the Y axis for 3 units (Fig. B) + ++----------------------------------------+----------------------------------------+ +| .. image:: ../_images/moveRel1.png | .. image:: ../_images/moveRel2.png | +| :scale: 60% | :scale: 60% | ++----------------------------------------+----------------------------------------+ + +Orient the Turtle +================= + +The Turtle's orientation can be setted using some primitives. + +*Pinpoint and PinpointRel* +-------------------------- + +.. _Pinpoint: + +**Pinpoint** orients the Turtle toward x,y and z given in arguments. It means that the H axis (the red arrow) will point to the coordinates given. One can use also a vector. + +.. code-block:: python + + Axiom: Pinpoint(1,0,0) Frame # The H axis point to (1,0,0) (Fig. A) + + import numpy as np + v = np.array([0,1,0]) + Axiom: Pinpoint(v) Frame # The H axis point to (0,1,0) (Fig. B) + + Axiom: Pinpoint(1,1,0) Frame # The H axis point to (1,1,0) (Fig. C) + +Download the example : :download:`orientation.lpy <../_downloads/orientation.lpy>` + ++-------------------------------------+-------------------------------------+-------------------------------------+ +| .. image:: ../_images/pinpoint1.png | .. image:: ../_images/pinpoint2.png | .. image:: ../_images/pinpoint3.png | +| :scale: 40% | :scale: 40% | :scale: 40% | ++-------------------------------------+-------------------------------------+-------------------------------------+ + +.. _PinpointRel: + +Such as **MoveRel** for position, **PinpointRel** orients the Turtle relatively to the current position. + +.. code-block:: python + + Axiom: Frame MoveTo(0,2,0) Pinpoint(1,0,1) Frame #(Fig. A) + + Axiom: Frame MoveTo(0,2,0) PinpointRel(1,0,1) Frame #(Fig. B) + ++----------------------------------------+----------------------------------------+ +| .. image:: ../_images/pinpointRel1.png | .. image:: ../_images/pinpointRel2.png | +| :scale: 60% | :scale: 60% | ++----------------------------------------+----------------------------------------+ + +*Setting the HLU axis* +---------------------- + +.. _setHead: + +The H and U axis can be set directly using **@R** (or **setHead**). The arguments needed are 6 floats (which represent the coordinates of the two axis) or two vectors. + +.. code-block:: python + + Axiom: Frame(2) @R(0,0,1,0,1,0) Frame(2) #(Fig. A) + + import numpy as np + h = np.array([0,1,0]) + u = np.array([1,0,1]) + Axiom: Frame(2) @R(h,u) Frame(2) #(Fig. B) + +Download the example : :download:`setHLU.lpy <../_downloads/setHLU.lpy>` + +In (Fig. A), the H axis point now to (0,0,1) but it was already the case and the U axis point now to (0,1,0). +In (Fig. B), the H axis point now to (0,1,0) and the U axis point now to (1,0,1). + ++-------------------------------------+-------------------------------------+ +| .. image:: ../_images/@R.png | .. image:: ../_images/@R2.png | +| :scale: 60% | :scale: 60% | ++-------------------------------------+-------------------------------------+ + +.. _EulerAngles: + +Finally, the Turtle’s orientation can at any moment be set using Euler angles with the primitive **EulerAngles**. The Euler angles are defined with respect to the other global reference frame (screen coordinates). By default, the initial Turtle’s frame is defined by the Euler angles (180,90,0) with respect to the original frame. + +.. code-block:: python + + Axiom: Frame(2) EulerAngles(0,0,0) Frame(2) # Turtle’s frame corresponds to the global reference frame. (Fig. A) + + Axiom: Frame(2) EulerAngles(180,0,0) Frame(2) #180° rotation arround Z axis. (Fig. B) + + Axiom: Frame(2) EulerAngles(180,90,0) Frame(2) #The 90° rotation arround the new Y axis. (Fig. C) + #There is the initial Turtle's frame + ++----------------------------------+----------------------------------+----------------------------------+ +| .. image:: ../_images/euler.png | .. image:: ../_images/euler2.png | .. image:: ../_images/euler3.png | +| :scale: 40% | :scale: 40% | :scale: 40% | ++----------------------------------+----------------------------------+----------------------------------+ + +.. code-block:: python + + #A succession of 3 rotations : First 30° arround Z axis (Fig. D), then 90° arround the new Y axis (Fig. E) + #and finally 60° arround the new X axis. (Fig. F) + Axiom: Frame(2) EulerAngles(30,90,60) Frame(2) + ++-----------------------------------+----------------------------------+----------------------------------+ +| .. image:: ../_images/euler4.png | .. image:: ../_images/euler5.png | .. image:: ../_images/euler6.png | +| :scale: 40% | :scale: 40% | :scale: 40% | ++-----------------------------------+----------------------------------+----------------------------------+ + + +*Long path* +----------- + +.. _nF: + +The primitive **nF** draws n steps of cylinders (n is the first argument). The size can be passed as a second argument. + +.. code-block:: python + + Axiom: nF(2,1)+(20)nF(2,1)+(20)@D(0.8)nF(3,1) #(Fig. A) + #Equivalent to FF+(20)FF+(20)@D(0.8)FFF + + #It can be used to create branching shapes too. + Axiom: nF(2,1)[+(45)nF(2,1)]nF(1,1)[-(45)nF(2,1)]nF(2,1) #(Fig. B) + +Download the example : :download:`longPath.lpy <../_downloads/longPath.lpy>` + ++--------------------------------+---------------------------------+ +| .. image:: ../_images/path.png | .. image:: ../_images/path2.png | +| :scale: 60% | :scale: 60% | ++--------------------------------+---------------------------------+ + +*Drawing lines* +--------------- + +.. _LineTo: + +The primitive **LineTo** allows to draw a cylinder from the current position of the Turtle to coordinates given in arguments. The topdiameter can also be given as a fourth argument. +Such as other primitives using coordinates, a vector can be used. + +.. code-block:: python + + Axiom: LineTo(0,0,3)[LineTo(0,1,4)]LineTo(0,0,5) #(Fig. A) + +Notice that **+**, **-**, **/** and other rotation primitives don't have any incidence on LineTo. + +.. code-block:: python + + Axiom: LineTo(0,0,3)[+(90)LineTo(0,1,4)]-(30)LineTo(0,0,5) #(Fig. B) + ++----------------------------------+-------------------------------------+ +| .. image:: ../_images/LineTo.png | .. image:: ../_images/LineToBis.png | +| :scale: 40% | :scale: 40% | ++----------------------------------+-------------------------------------+ + +.. _OLineTo: + +**LineTo** conserve the Turtle's orientation. To change orientation while drawing, **OLineTo** should be used. + +.. code-block:: python + + Axiom: LineTo(0,0,2)[LineTo(0,1,3)Frame]LineTo(0,0,3)[LineTo(0,-1,4)Frame]LineTo(0,0,5) #(Fig. A) + + Axiom: LineTo(0,0,2)[OLineTo(0,1,3)Frame]LineTo(0,0,3)[OLineTo(0,-1,4)Frame]LineTo(0,0,5) #(Fig. B) + +Download the example : :download:`LineTo.lpy <../_downloads/LineTo.lpy>` + ++-----------------------------------+-----------------------------------+ +| .. image:: ../_images/LineTo2.png | .. image:: ../_images/OLineTo.png | +| :scale: 40% | :scale: 40% | ++-----------------------------------+-----------------------------------+ + +.. _LineRel: + +.. _OLineRel: + +A relative drawing alternative also exists for **LineTo** and **OLineTo**. These primitives are **LineRel** and **OLineRel** + +.. code-block:: python + + Axiom: LineTo(0,0,2)[LineTo(0,1,2)]LineTo(0,0,4) #(Fig. A) + + Axiom: LineTo(0,0,2)[LineRel(0,1,2)]LineTo(0,0,4) #(Fig. B) + ++------------------------------------+------------------------------------+ +| .. image:: ../_images/LineRel1.png | .. image:: ../_images/LineRel2.png | +| :scale: 50% | :scale: 50% | ++------------------------------------+------------------------------------+ + +*SetGuide* +---------- + +.. _SetGuide: + +Drawing a straight line made of length **l=10** with segments of size **dl = 1.0** (and thus contains n= 10 segments) + +.. code-block:: python + + Axiom: nF(10, 1.) #(Fig. A) + +By adding the primitive SetGuide before the line drawing, it is possible to specify a curve on which the Turtle is moving (instead of heading straight). + + +The **SetGuide** primitive must be given two mandatory arguments: a curve (Polyline2D or NurbsCurve2D) and a length: **SetGuide(C0, L0)**. This means that, following this statement, the Turtle will move on curve **C1** that has been rescaled from **C0** so that its new length is **L0** (whatever its original length). + +The guiding curve can be defined in different ways. It can be defined for example by a python function (**function f** defined hereafter), e.g. (Fig. B) : + +.. code-block:: python + + from openalea.plantgl.all import Polyline2D + from numpy import arange + + def f(u): + return (u,u**2) + + C0 = Polyline2D([f(u) for u in arange(0,1,0.1)]) # (Fig. B) + +Then using curve **C0** in the **SetGuide** primitive, one can move the Turtle over a cumulated length **L**, thus using the defined curve **C1** (rescaled from **C0**) as a guide for moving up to a total length **L0**: + +.. code-block:: python + + L = 10 + L0 = 10 + Axiom: SetGuide(C0,L0) nF(L, 0.1) + +Download the example : :download:`setGuide1.lpy <../_downloads/setGuide1.lpy>` (With a Polyline2D imported from PlantGL) + ++-------------------------------------+-------------------------------------+ +| .. image:: ../_images/setGuide1.png | .. image:: ../_images/setGuide2.png | +| :scale: 50% | :scale: 50% | ++-------------------------------------+-------------------------------------+ + +or like the *(Fig. C)* example, the embedded L-Py graphical interface can be used to specifying 2D curves (the curve is then given the name **C0** for instance in the interface): + ++---------------------------------+-------------------------------------+ +| .. image:: ../_images/ex009.png | .. image:: ../_images/setGuide3.png | +| :scale: 40% | :scale: 60% | ++---------------------------------+-------------------------------------+ + +Download the example : :download:`setGuide2.lpy <../_downloads/setGuide2.lpy>` (With a Polyline2D created in the L-Py graphical interface) + +Note that the Turtle can move less than the length of the 2D curve. In this case it will proceed forward over the **L** first units at the beginning of curve **C1** (Fig. D). By contrast, if **L** > **L0**, then the Turtle keeps on moving straight after reaching length **L0** (E). + +.. code-block:: python + + L = 6 + L0 = 10 + Axiom: SetGuide(C0,L0) nF(L, 0.1) # (Fig. D) + + L = 15 + L0 = 10 + Axiom: SetGuide(C0,L0) nF(L, 0.1) # (Fig. E) + ++-------------------------------------+-------------------------------------+ +| .. image:: ../_images/setGuide4.png | .. image:: ../_images/setGuide5.png | +| :scale: 50% | :scale: 50% | ++-------------------------------------+-------------------------------------+ + +To stop using the 2D curve as a guide, **EndGuide** can be used. + +*Generalized cylinders* +----------------------- + +.. _generalisedCylinders: + +When several rotations are used while drawing, the render at rotation places isn't great. The separation points are really visible. To fix it, **@Gc** (or **StartGC**) can be used. +Until a **@Ge** (or **"EndGC**") all shapes drawn will be merged that so it becomes only one shape. + +.. code-block:: python + + Axiom: F(2)+(30)F+(30)F+(30)F+(45)F+(45)F@O #Cylinders not generalized (Fig. A) + + Axiom: @GcF(2)+(30)F+(30)F+(30)F+(45)F+(45)F@O@Gc #Cylinders generalized (Fig. B) + +Download the example : :download:`generalizedCylinders.lpy <../_downloads/generalizedCylinders.lpy>` + ++------------------------------------------+---------------------------------------+ +| .. image:: ../_images/notGeneralized.png | .. image:: ../_images/generalized.png | +| :scale: 50% | :scale: 50% | ++------------------------------------------+---------------------------------------+ diff --git a/doc/user/tutorial.rst b/doc/user/tutorial.rst new file mode 100644 index 00000000..69cf61ef --- /dev/null +++ b/doc/user/tutorial.rst @@ -0,0 +1,4 @@ +Beginner's Tutorial +################### + +In order to acquire the basics about L-Py, we recommend you to follow this short tutorial. \ No newline at end of file