The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Math::Fractal::Julia - Calculate points in the Julia set

VERSION

version 0.000002

SYNOPSIS

    use Math::Fractal::Julia;

    # Procedural usage:
    Math::Fractal::Julia->set_max_iter($iters);
    Math::Fractal::Julia->set_limit($limit);
    Math::Fractal::Julia->set_bounds( $x1, $y1, $x2, $y2, $w, $h );
    Math::Fractal::Julia->set_constant( $cx, $cy );
    for my $y ( 0 .. $h - 1 ) {
        for my $x ( 0 .. $w - 1 ) {
            my $iter = Math::Fractal::Julia->point( $x, $y );
        }
    }

    # Object Oriented usage:
    my $julia = Math::Fractal::Julia->new(%options);
    $julia->set_max_iter($iters);
    $julia->set_limit($limit);
    $julia->set_bounds( $x1, $y1, $x2, $y2, $w, $h );
    $julia->set_constant( $cx, $cy );
    for my $y ( 0 .. $h - 1 ) {
        for my $x ( 0 .. $w - 1 ) {
            my $iter = $julia->point( $x, $y );
        }
    }

DESCRIPTION

Calculates points in the set named after the French mathematician Gaston Julia.

The procedural interface is based on that provided by Math::Fractal::Mandelbrot.

METHODS

new

Arguments: %options?
Return value: A Math::Fractal::Julia object

Options:

  • max_iter => $iters

  • limit => $limit

  • bounds => [ $x1, $x2, $y1, $y2, $width, $height ]

  • constant => [ $cx, $cy ]

    my $julia = Math::Fractal::Julia->new();
    my $julia = Math::Fractal::Julia->new(%options);

Creates a new Math::Fractal::Object. If no options are provided, the default values will be used.

set_max_iter

Arguments: $max
    Math::Fractal::Julia->set_max_iter($max);
    $julia->set_max_iter($max);

Set the maximum number of iterations. The default value is 600.

set_limit

Arguments: $limit
    Math::Fractal::Julia->set_limit($limit);
    $julia->set_limit($limit);

The default value is 5.

set_bounds

Arguments: $x1, $y1, $x2, $y2, $width, $height
    Math::Fractal::Julia->set_bounds( $x1, $y1, $x2, $y2, $width, $height );
    $julia->set_bounds( $x1, $x2, $y1, $y2, $width, $height );

Set the bounds of the set. The first four values ($x1, $y1, $x2, $y2) define a rectangle. The remaining two ($width, $height) define a viewport. The default values are (-2.2, -1.1, 1.0, 1.1, 640, 480).

set_constant

Arguments: $cx, $cy
    Math::Fractal::Julia->set_constant( $cx, $cy );
    $julia->set_constant( $cx, $cy );

The default values are (0.0, 0.0).

point

Arguments: $x, $y
Return value: The number of iterations needed to exceed the limit or 0 if the the limit is not exceeded.
    $iter = Math::Fractal::Julia->point( $x, $y );
    $iter = $julia->point( $x, $y );

This function translates the coordinates using the bounds and then iterates.

BUGS AND LIMITATIONS

  • This module is not thread-safe.

  • Any packages derived from Math::Fractal::Julia will share the same internal state when used procedurally.

SEE ALSO

AUTHOR

Jeffrey T. Palmer <jtpalmer@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Jeffrey T. Palmer.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.