Casey Vega > Geometry-Formula > Geometry::Formula

Download:
Geometry-Formula-0.02.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.02   Source  

NAME ^

Geometry::Formula - methods to calculate common geometry formulas.

VERSION ^

    Version 0.01

SYNOPSIS ^

    use Geometry::Formula

    my $x = Geometry::Formula->new;

DESCRIPTION ^

This package provides users with the ability to calculate simple geometric problems using the most common geometry formulas. This module was primarily written for education and practical purposes.

CONSTRUCTOR ^

new()

Returns a reference to a new formula object. No arguments currently needed or required.

SUBROUTINES/METHODS ^

The following methods are used to calculate our geometry formulas. Keep in mind each formula has a unique set of constructors/parameters that are used and must be provided accordingly. All attempts have been made to prevent a user from providing invalid data to the method.

Methods are named after the 2d and 3d shapes one would expect to find while using geometric formulas such as square or cube. Please see the individual method items for the specific parameters one must use. In the example below you can see how we make usage of Geometry::Formula:

    use Geometry::Formula;

    my $x   = Geometry::Formula->new;
    my $sqr = $x->square{ formula => 'area', side => 5 };

    print $sqr;
    ---
    25
annulus()

The annulus method provides an area formula.

required: inner_radius, outer_radius

    $x->annulus{
        formula      => 'area',
        inner_radius => int,
        outer_radius => int
    };

Note: the inner_radius cannot be larger then the outer_radius.

circle()

The circle method provides an area, circumference, and diameter formula.

required: radius

    $x->circle(
        formula => 'area',
        radius  => int
    );

    $x->circle(
        formula => 'circumference',
        radius  => int
    );

    $x->circle(
        formula => 'diameter',
        radius  => int
    );
cone()

The cone method provides a volume formula.

required: base, height

    $x->cone(
        formula => 'volume',
        base    => int,
        height  => int
    );
cube()

The cube method provides a surface area and volume formula.

required: a

    $x->cube(
        formula => 'surface_area',
        a       => int
    );

    $x->cube(
        formula => 'volume',
        a       => int
    );
ellipse()

The ellipse method provides an area and perimeter formula.

required: a, b

    $x->ellipse(
        formula => 'area',
        a       => int,
        b       => int
    );

    $x->ellipse(
        formula => 'perimeter',
        a       => int,
        b       => int
    );

Note: a and b represent radii

ellipsoid()

The ellipsoid method provides a volume formula.

required: a, b, c

    x->ellipsoid(
        formula => 'volume',
        a       => int,
        b       => int,
        c       => int,
    );

Note: a, b, and c represent radii

equilateral_triangle()

The equalateral_triangle method provides an area formula.

required: side

    x->equilateral_triangle(
        formula => 'area',
        side    => int,
    );
frustum_of_right_circular_cone()

The frustum_of_right_circular_cone method provides a lateral_surface_area, total_surface_area, and volume formula.

required: slant_height, large_radius, small_radius

    x->frustum_of_right_circular_cone(
        formula      => 'lateral_surface_area',
        slant_height => int,
        large_radius => int,
        small_radius => int
    );

required: height, large_radius, small_radius

    x->frustum_of_right_circular_cone(
        formula      => 'total_surface_area',
        height       => int,
        large_radius => int,
        small_radius => int

    );

    x->frustum_of_right_circular_cone(
        formula      => 'volume',
        height       => int,
        large_radius => int,
        small_radius => int
    );
parallelogram()

The parallelogram method provides an area and perimeter formula.

required: base, height

    x->parallelgram(
        formula => 'area',
        base    => int,
        height  => int
    );

required: a, b

    x->parallelgram(
        formula => 'perimeter',
        a       => int,
        b       => int
    );

Note: a and b are sides

rectangle()

The rectangle method provides an area and perimeter formula.

required: length, width

    x->rectangle(
        formula => 'area',
        length  => int,
        width   => int
    );

    x->rectangle(
        formula => 'perimeter',
        length  => int,
        width   => int
    );
rectangular_solid()

The rectangular_solid method provides an and perimeter formula.

required: length, width, height

    x->rectangular_solid(
        formula => 'surface_area',
        length  => int,
        width   => int,
        height  => int
    );

    x->rectangular_solid(
        formula => 'volume',
        length  => int,
        width   => int,
        height  => int
    );
rhombus()

The rhombus method provides an area formula.

required: a, b

    x->rhombus(
        formula => 'area',
        a       => int,
        b       => int
    );

Note: a and b represent diagonal lines (sides)

right_circular_cone()

The right_circular_cone method provides a lateral surface area formula.

required: height, radius

    $x->right_circular_cone(
        formula => 'lateral_surface_area', 
        height  => int,
        radius  => int
    );
right_circular_cylinder()

The right_circular_cylinder method provides a side surface area, total surface area, and volume formula.

required: height, radius

    $x->right_circular_cylinder(
        formula => 'lateral_surface_area', 
        height  => int,
        radius  => int
    );

    $x->right_circular_cylinder(
        formula => 'total_surface_area', 
        height  => int,
        radius  => int
    );

    $x->right_circular_cylinder(
        formula => 'volume', 
        height  => int,
        radius  => int
    );
sector_of_circle()

The sector_of_circle method provides an area formula.

required: theta

    $x->sector_of_circle(
        formula => 'area', 
        theta   => int
    );

Note: theta value should not be greater then 360 (degrees).

sphere()

The sphere method provides a surface area and volume formula.

required: radius

    $x->sphere(
        formula => 'surface_area', 
        radius  => int
    );

    $x->sphere(
        formula => 'volume', 
        radius  => int
    );
square()

The square method provides an area and perimeter formula.

required: side

    $x->square(
        formula => 'area', 
        side    => int
    );

    $x->square(
        formula => 'perimeter', 
        side    => int
    );
torus()

The torus method provides a surface area and volume formula.

    $x->torus(
        formula => 'surface_area', 
        a       => int,
        b       => int
    );

    $x->torus(
        formula => 'volume', 
        a  => int,
        b  => int
    );

Note: a and b represent radii

trapezoid()

The trapezoid method provides an area and perimeter formula.

required: a, b, and height

    $x->trapezoid(
        formula => 'area', 
        a       => int,
        b       => int,
        height  => int
    );

required a, b, c, and d

    $x->trapezoid(
        formula => 'perimeter', 
        a       => int,
        b       => int,
        c       => int,
        d       => int
    );
triangle()

The triangle method provides an area and perimeter formula.

    $x->triangle(
        formula => 'area', 
        base    => int,
        height  => int
    );

    $x->triangle(
        formula => 'perimeter', 
        a  => int,
        b  => int,
        c  => int
    );

HELPER SUBROUTINES/METHODS ^

While documented typically you will not call these methods directly. These methods are provided for readability and parameter validation.

$self->_squared( int )

numeric values passed to this function get $self->_squared and returned.

<$self-_cubed( int ) >>

numeric values passed to this fucntion get$self->_cubed and returned

_param_check( $name_of_method, %param )

this method validates the parameters being passed into our formula methods are properly constructed.

DIAGNOSTICS ^

N/A at the current point in time

CONFIGURATION AND ENVIRONMENT ^

This package has only been tested in a 64bit Unix (OSX) environment however it does not make usage of any code or modules considered OS specific and no special configuration or configuration files are needed.

INCOMPATIBILITIES ^

This package is intended to be compatible with Perl 5.008 and beyond.

BUGS AND LIMITATIONS ^

The package cannot prevent users from specifying duplicate keys within a method. When validating parameters the first error that is caught will be reported even in the event that additional errors exist. The methods provided were not intended to handle very large numbers.

DEPENDENCIES ^

No modules outside of the perl core/base install.

SEE ALSO ^

Carp

SUPPORT ^

The module is provided free of support however feel free to contact the author or current maintainer with questions, bug reports, and patches.

Consideration will be taken when making changes to the API. Any changes to its interface will go through at the least one deprecation cycle.

LICENSE AND COPYRIGHT ^

Copyright (c) 2011 Casey W. Vega.

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

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.

Author ^

Casey Vega <cvega@cpan.org>

syntax highlighting: