.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Sinewave 3pm" .TH Sinewave 3pm "2023-01-27" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Tie::Cycle::Sinewave \- Cycle through a series of values on a sinewave .SH "VERSION" .IX Header "VERSION" This document describes version 0.05 of Tie::Cycle::Sinewave, released 2007\-11\-07. .SH "SYNOPSIS" .IX Header "SYNOPSIS" This module allows you to make a scalar iterate through the values on a sinewave. You set the maximum and minimum values and the number of steps and you're set. .PP .Vb 2 \& use strict; \& use Tie::Cycle::Sinewave; \& \& tie my $cycle, \*(AqTie::Cycle::Sinewave\*(Aq, { \& min => 10, \& max => 50, \& period => 12, \& }; \& printf("%0.2f\en", $cycle) for 1..10; .Ve .SH "PARAMETERS" .IX Header "PARAMETERS" A number of parameters can be passed in to the creation of the tied object. They are as follows (in order of likely usefulness): .IP "min" 4 .IX Item "min" Sets the minimum value. If not specified, 0 will be used as a default minimum. .IP "max" 4 .IX Item "max" Sets the maximum value. Should be higher than min, but the values will be swapped if necessary. If not specified, 100 will be used as a default maximum. .IP "period" 4 .IX Item "period" Sets the period of the curve. The cycle will go through this many values from min to max. If not specified, 20 will be used as a default. If period is set to 0, it will be silently changed to 1, to prevent internal calculations from attempting to divide by 0. .IP "start_max" 4 .IX Item "start_max" Optional. When set to 1 (or anything), the cyle will start at the maximum value. (\f(CW\*(C`startmax\*(C'\fR exists as a an alias). .IP "start_min" 4 .IX Item "start_min" Optional. When set to 1 (or anything), the cyle will start at the minimum value. (\f(CW\*(C`startmin\*(C'\fR exists as a an alias). If neither \&\f(CW\*(C`start_max\*(C'\fR nor \f(CW\*(C`start_min\*(C'\fR are specified, it will at the origin (thus, mid-way between min and max and will move to max). .IP "at_max" 4 .IX Item "at_max" Optional. When set to a coderef, will be executed when the cycle reaches the maximum value. This allows the modification of the cycle, \fIe.g.\fR modifying the minimum value or the period. (The key \&\f(CW\*(C`atmax\*(C'\fR exists as an alias). .IP "at_min" 4 .IX Item "at_min" Optional. When set to a coderef, will be executed when the cycle reaches the minimum value. This allows the modification of the cycle, \fIe.g.\fR modifying the maximum value or the period. (The key \&\f(CW\*(C`atmin\*(C'\fR exists as an alias). .SH "OBJECT METHODS" .IX Header "OBJECT METHODS" You can call methods on the underlying object (which you access with the \&\f(CW\*(C`tied()\*(C'\fR function). Have a look at the file \f(CW\*(C`eg/callback\*(C'\fR for an example on what you might want to do with these. .IP "min" 4 .IX Item "min" When called without a parameter, returns the current minimum value. When called with a (numeric) parameter, sets the new current minimum value. The previous value is returned. .Sp .Vb 2 \& my $min = (tied $cycle)\->min(); \& (tied $cycle)\->min($min \- 20); .Ve .IP "max" 4 .IX Item "max" When called without a parameter, returns the current maximum value. When called with a (numeric) parameter, sets the new current maximum value. The previous value is returned. .Sp .Vb 2 \& my $max = (tied $cycle)\->max(); \& (tied $cycle)\->max($max * 10); .Ve .Sp When \f(CW\*(C`min\*(C'\fR or \f(CW\*(C`max\*(C'\fR are modified, a consistency check is run to ensure that \f(CW\*(C`min <= max\*(C'\fR. If this check fails, the two values are quietly swapped around. .IP "period" 4 .IX Item "period" When called without a parameter, returns the current period. When called with a (numeric) parameter, sets the new current period. The previous value is returned. .IP "angle" 4 .IX Item "angle" Returns the current angle of the sine, which is guaranteed to be in the range \f(CW\*(C` 0 <= angle <= 2*PI\*(C'\fR. .SH "AUTHOR" .IX Header "AUTHOR" David Landgren. .SH "SEE ALSO" .IX Header "SEE ALSO" .Vb 2 \& L \& L .Ve .SH "BUGS" .IX Header "BUGS" Please report any bugs or feature requests to \&\f(CW\*(C`bug\-tie\-cycle\-sinewave@rt.cpan.org\*(C'\fR, or through the web interface at . .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright 2005\-2007 David Landgren, All Rights Reserved. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.