CurveTrap Functions |
|
|
CurveTrap Functions SupportThe Fractal Science Kit fractal generator CurveTrap functions are supported only in the Orbit Trap instructions. Each set of instructions has access to a single CurveTrap object that you can use to implement your trap. The CurveTrap object maintains a set of curves that are combined to form the trap. You should call CurveTrap.Initialize before you call any of the other methods. Next you should call 1 or more of the CurveTrap.Add... methods to add different curves to the set. The calls to CurveTrap.Initialize and each of the CurveTrap.Add... methods should be placed in the global section of your instructions. Finally, in the trap section of your instructions, you should call CurveTrap.Apply to calculate the trap's required TrappedPointInfo. The CurveTrap functions are highly optimized and can dramatically speed up your program. However, performance will suffer if you add a large number of curves to the trap (> 2500) . Example: global: This example shows the typical pattern used to implement a trap using the CurveTrap methods. Example: comment: These instructions implement a simple circle orbit trap with options to control the Center and Radius of the circle and the width of the line on either side of the curve (LineWidth). The built-in Orbit Traps include many examples of using these methods. CurveTrap.Initializevoid CurveTrap.Initialize( CurveTrap.Initialize initializes the CurveTrap object based on the given arguments. The center, angle, and scale, set the center point, angle of inclination, and scale factor for the entire set of curves. The Boolean argument alternateAngle controls the algorithm used to calculate the trapped point angle. Normally, the angle of each trapped point is the angle of the point relative to the trap's center. However, if alternateAngle is true, the method used to compute the angle depends on the type of curve. For shapes, the alternate angle is relative to each shape's center rather than the center of the entire trap. For all other curves, the alternate angle is based on how far along the curve's path the point is; i.e., the angle ranges from 0 to 2*Math.PI as the point traverses along the path of the curve. In other words, if alternateAngle is true, the angle is relative to each of the trap's individual curves rather than relative to the entire set. You will normally want to set alternateAngle to true when you are using the trap with a controller that maps a texture or pattern onto the surface of the trap, unless you are using a planar projection, in which case you should set alternateAngle to false. The cycleLength argument is used only for lines and only if alternateAngle is true. It is the distance along the line that maps to 2*Math.PI when computing the trapped point angle. The scaleTrapValue argument is a Boolean value that, when true, instructs the CurveTrap to scale trap values proportional to how far the trapped point is from the origin. This makes lines get wider as they move away from the origin and narrower as the move closer to the origin. The lineWidth argument controls the extent of non-solid traps on either side of the curve. Typically, you will provide options in your trap's properties section to allow the user to control 1 or more of these settings and call CurveTrap.Initialize with the user's selections. CurveTrap.Add... Common ArgumentsAll of the CurveTrap.Add... methods share 3 arguments: level, index, and delta. The level argument is rarely set to a value other than 0, but can be used to force selected curves above other curves by setting their level higher. That is, all curves of level 0 will be displayed below curves of level 1, and they in turn will be below curves of level 2, etc. If all the levels are 0, all the curves will be blended into a single level. Setting level to a value other than 0 is less efficient than setting all levels to 0. The index argument can be used to assign each curve a different index value which can be mapped to the trap index value and accessed by the controller and used to color the trap. Set the Trap Index Map to Trap Index on the Orbit Trap Map properties page if you need to access the assigned index value in your controller. The delta argument can be used to assign each curve a different delta value which can be mapped to the trap delta value and accessed by the controller and used to color the trap. Set the Trap Delta Map to Trap Delta on the Orbit Trap Map properties page if you need to access the assigned delta value in your controller. If either of these values are not required for your trap, simply pass 0 for the associated argument. CurveTrap.AddCurvevoid CurveTrap.AddCurve( CurveTrap.AddCurve adds a curve (set of line segments) through the count points in the points[] array. If the Boolean argument closed is true, the last point is connected to the first. Otherwise the curve is left open. The arguments scale, angle, and shift, apply a scaling, rotation, and translation to the curve points relative to the origin. The cornerStyle argument is one of the values from the CornerStyles enum and defines the style applied to each point. You should use the value CornerStyles.Round unless the number of points is small. cornerStyle is ignored and the curve displayed with CornerStyles.Round if the curve is open. The CornerStyles enum is defined in the built-in macros as: #define CornerStyles Use the following statement in the properties section to define the enum in your program: #include CornerStyles CurveTrap.AddShapevoid CurveTrap.AddShape( CurveTrap.AddShape adds a shape from the ShapeTypes enum. The type argument specifies the shape type. Arguments center, radius, and angle, control the position, size, and inclination of the resulting shape. If solid is true the shape is displayed as a solid figure. Otherwise, the curve outlines the shape. You can access the list of types by including the following statement in your properties section: #include ShapeTypes See Shape Functions for the full list of types defined by ShapeTypes. CurveTrap.AddCirclevoid CurveTrap.AddCircle( CurveTrap.AddCircle adds a circle with the given center and radius. If solid is true the circle is displayed as a solid figure. Otherwise, the curve outlines the circle. CurveTrap.AddCircle2 is identical to CurveTrap.AddCircle but it takes the center and radius from the argument c. CurveTrap.CircleExists returns True if a circle with the given center and radius exists in the set of curve traps already defined. CurveTrap.CircleExists2 is identical to CurveTrap.CircleExists but it takes the center and radius from the argument c. CurveTrap.AddLinevoid CurveTrap.AddLine( CurveTrap.AddLine adds a line through point, inclined at angle radians. CurveTrap.AddLine2 adds a line through the points p0 and p1. CurveTrap.AddSegmentvoid CurveTrap.AddSegment( CurveTrap.AddSegment adds a line segment with endpoints p0 and p1. CurveTrap.SegmentExists returns True if a segment with the given endpoints p0 and p1 exists in the set of curve traps already defined. CurveTrap.ApplyTrappedPointInfo CurveTrap.Apply(z) CurveTrap.Apply applies the set of curves to the point z returning the required TrappedPointInfo. |
|
Copyright © 2004-2010 Hilbert, LLC |