view release on metacpan or search on metacpan
ex/benchmark.pl view on Meta::CPAN
# Uses lat/lon instead of lon/lat
my $d = $gis->distance(@coord[ 1, 0, 3, 2 ]);
return $d->mile;
}
my %gis_formula = (
hsin => 'Haversine',
polar => 'Polar',
cos => 'Cosine',
gcd => 'GreatCircle',
mt => 'MathTrig',
tv => 'Vincenty',
);
for my $formula (qw(hsin tv polar cos gcd mt)) {
print "---- [ Formula: $formula ] ------------------------------------\n";
$geo->formula($formula);
$gis->formula($gis_formula{$formula});
Geo::Distance::XS->unimport;
printf "perl - distance from LA to NY: %s miles\n", geo();
Geo::Distance::XS->import;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Geo/Distance.pm view on Meta::CPAN
sub new {
my $class = shift;
my $self = bless {}, $class;
my %args = @_;
$self->{formula} = 'hsin';
$self->{units} = {};
if(!$args{no_units}){
$self->reg_unit( $KILOMETER_RHO, 'kilometer' );
$self->reg_unit( 1000, 'meter', => 'kilometer' );
$self->reg_unit( 100, 'centimeter' => 'meter' );
lib/Geo/Distance.pm view on Meta::CPAN
}
return $self;
}
sub formula {
my $self = shift;
return $self->{formula} if !$_[0];
my $formula = shift;
my $gis_formula = $GEO_TO_GIS_FORMULA_MAP{ $formula };
croak(
'Unknown formula (available formulas are ',
join(', ', sort @FORMULAS),
')',
) if !$gis_formula;
$self->{formula} = $formula;
$self->{gis_formula} = $gis_formula;
return $formula;
}
sub distance {
my ($self, $unit, $lon1, $lat1, $lon2, $lat2) = @_;
my $unit_rho = $self->{units}->{$unit};
croak('Unkown unit type "' . $unit . '"') if !$unit_rho;
my $gis = GIS::Distance->new( $self->{gis_formula} );
# Reverse lon/lat to lat/lon, the way GIS::Distance wants it.
my $km = $gis->{code}->( $lat1, $lon1, $lat2, $lon2 );
return $km * ($unit_rho / $KILOMETER_RHO);
lib/Geo/Distance.pm view on Meta::CPAN
sub old_distance {
my($self,$unit,$lon1,$lat1,$lon2,$lat2) = @_;
croak('Unkown unit type "'.$unit.'"') unless($unit = $self->{units}->{$unit});
return 0 if $self->{formula} eq 'null';
return 0 if $self->{formula} eq 'alt';
if($self->{formula} eq 'mt'){
return great_circle_distance(
deg2rad($lon1),
deg2rad(90 - $lat1),
deg2rad($lon2),
deg2rad(90 - $lat2),
lib/Geo/Distance.pm view on Meta::CPAN
}
$lon1 = deg2rad($lon1); $lat1 = deg2rad($lat1);
$lon2 = deg2rad($lon2); $lat2 = deg2rad($lat2);
my $c;
if($self->{formula} eq 'cos'){
my $a = sin($lat1) * sin($lat2);
my $b = cos($lat1) * cos($lat2) * cos($lon2 - $lon1);
$c = acos($a + $b);
}
elsif($self->{formula} eq 'hsin'){
my $dlon = $lon2 - $lon1;
my $dlat = $lat2 - $lat1;
my $a = (sin($dlat/2)) ** 2 + cos($lat1) * cos($lat2) * (sin($dlon/2)) ** 2;
$c = 2 * atan2(sqrt($a), sqrt(abs(1-$a)));
}
elsif($self->{formula} eq 'polar'){
my $a = pi/2 - $lat1;
my $b = pi/2 - $lat2;
$c = sqrt( $a ** 2 + $b ** 2 - 2 * $a * $b * cos($lon2 - $lon1) );
}
elsif($self->{formula} eq 'gcd'){
$c = 2*asin( sqrt(
( sin(($lat1-$lat2)/2) )**2 +
cos($lat1) * cos($lat2) *
( sin(($lon1-$lon2)/2) )**2
) );
# Eric Samuelson recommended this formula.
# http://forums.devshed.com/t54655/sc3d021a264676b9b440ea7cbe1f775a1.html
# http://williams.best.vwh.net/avform.htm
# It seems to produce the same results at the hsin formula, so...
#my $dlon = $lon2 - $lon1;
#my $dlat = $lat2 - $lat1;
#my $a = (sin($dlat / 2)) ** 2
# + cos($lat1) * cos($lat2) * (sin($dlon / 2)) ** 2;
#$c = 2 * atan2(sqrt($a), sqrt(1 - $a));
}
elsif($self->{formula} eq 'tv'){
my($a,$b,$f) = (6378137,6356752.3142,1/298.257223563);
my $l = $lon2 - $lon1;
my $u1 = atan((1-$f) * tan($lat1));
my $u2 = atan((1-$f) * tan($lat2));
my $sin_u1 = sin($u1); my $cos_u1 = cos($u1);
lib/Geo/Distance.pm view on Meta::CPAN
my $delta_sigma = $bb*$sin_sigma*($cos2sigma_m+$bb/4*($cos_sigma*(-1+2*$cos2sigma_m*$cos2sigma_m)-
$bb/6*$cos2sigma_m*(-3+4*$sin_sigma*$sin_sigma)*(-3+4*$cos2sigma_m*$cos2sigma_m)));
$c = ( $b*$aa*($sigma-$delta_sigma) ) / $self->{units}->{meter};
}
else{
croak('Unkown distance formula "'.$self->{formula}.'"');
}
return $unit * $c;
}
lib/Geo/Distance.pm view on Meta::CPAN
=head1 SYNOPSIS
use Geo::Distance;
my $geo = new Geo::Distance;
$geo->formula('hsin');
$geo->reg_unit( 'toad_hop', 200120 );
$geo->reg_unit( 'frog_hop' => 6 => 'toad_hop' );
my $distance = $geo->distance( 'unit_type', $lon1,$lat1 => $lon2,$lat2 );
lib/Geo/Distance.pm view on Meta::CPAN
Set this to disable the loading of the default units as described in L</UNITS>.
=head1 ACCESSORS
=head2 formula
if ($geo->formula() eq 'hsin') { ... }
$geo->formula('cos');
Set and get the formula that is currently being used to calculate distances.
See the available L</FORMULAS>.
C<hsin> is the default.
=head1 METHODS
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Geo/ECEF.pm view on Meta::CPAN
=head1 DESCRIPTION
Geo::ECEF provides two methods ecef and geodetic. The ecef method calculates the X,Y and Z coordinates in the ECEF (earth centered earth fixed) coordinate system from latitude, longitude and height above the ellipsoid. The geodetic method calculate...
The formulas were found at http://www.u-blox.ch/ and http://waas.stanford.edu/~wwu/maast/maastWWW1_0.zip.
This code is an object Perl rewrite of a similar package by Morten Sickel, Norwegian Radiation Protection Authority
=head1 CONSTRUCTOR
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Geo/Ellipsoids.pm view on Meta::CPAN
my $lat = shift; #radians
die('Error: Latitude (radians) required.') unless defined $lat;
my $a = $self->a;
my $e2 = $self->e2;
return $a * (1-$e2) / ( 1 - $e2 * sin($lat)**2 )**(3/2)
#return $a * (1-$e2) / sqrt(1 - $e2 * sin($lat)**(3/2)); #Bad formula from somewhere
}
=head2 polar_circumference
Method returns the value of the semi-minor axis times 2*PI.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Geo/Functions.pm view on Meta::CPAN
return rad_deg(deg_dms(@_));
}
=head2 round
Round to the nearest integer. This formula rounds toward +/- infinity.
my $int = round(42.2);
=cut
view all matches for this distribution
view release on metacpan or search on metacpan
# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This
# cache is used to resolve symbols given their name and scope. Since this can be
# an expensive process and often the same symbol appears multiple times in the
# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small
# doxygen will become slower. If the cache is too large, memory is wasted. The
# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range
# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536
# symbols. At the end of a run doxygen will report the cache usage and suggest
# the optimal cache size from a speed point of view.
# Minimum value: 0, maximum value: 9, default value: 0.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
EXT_LINKS_IN_WINDOW = NO
# Use this tag to change the font size of LaTeX formulas included as images in
# the HTML documentation. When you change the font size after a successful
# doxygen run you need to manually remove any form_*.png images from the HTML
# output directory to force them to be regenerated.
# Minimum value: 8, maximum value: 50, default value: 10.
# This tag requires that the tag GENERATE_HTML is set to YES.
FORMULA_FONTSIZE = 10
# Use the FORMULA_TRANSPARENT tag to determine whether or not the images
# generated for formulas are transparent PNGs. Transparent PNGs are not
# supported properly for IE 6.0, but are supported on all modern browsers.
#
# Note that when changing this option you need to delete any form_*.png files in
# the HTML output directory before the changes have effect.
# The default value is: YES.
# This tag requires that the tag GENERATE_HTML is set to YES.
FORMULA_TRANSPARENT = YES
# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
# http://www.mathjax.org) which uses client side Javascript for the rendering
# instead of using prerendered bitmaps. Use this if you do not have LaTeX
# installed or if you want to formulas look prettier in the HTML output. When
# enabled you may also need to install MathJax separately and configure the path
# to it using the MATHJAX_RELPATH option.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
# invoked.
#
# Note that when enabling USE_PDFLATEX this option is only used for generating
# bitmaps for formulas in the HTML output, but not in the Makefile that is
# written to the output directory.
# The default file is: latex.
# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_CMD_NAME = latex
USE_PDFLATEX = YES
# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode
# command to the generated LaTeX files. This will instruct LaTeX to keep running
# if errors occur, instead of asking the user for help. This option is also used
# when generating formulas in HTML.
# The default value is: NO.
# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_BATCHMODE = NO
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Geo/GML/xsd/gml-3.0.0/base/coordinateOperations.xsd view on Meta::CPAN
<element name="methodID" type="gml:IdentifierType">
<annotation>
<documentation>Identification of this operation method. </documentation>
</annotation>
</element>
<element name="formula" type="string">
<annotation>
<documentation>Formula(s) used by this operation method. The value may be a reference to a publication. Note that the operation method may not be analytic, in which case this element references or contains the procedure, not an analytic...
</annotation>
</element>
</sequence>
</extension>
</complexContent>
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Geo/GNUPlot.pm view on Meta::CPAN
The radius function is controlled by user defined node values
on a user defined irregular grid. Values between the nodes
are computed using two dimensional linear interpolation. I used
Numerical Recipes in Fortran 77 page 117 equations 3.6.3, 3.6.4, and
3.6.5 as a reference. It is a simple formula and can be derived
from scratch without too much effort. If you don't like this approach
then simply override the radius_function method with your own. Better
yet, provide your improved version to the current maintainer of this
package. In the event Jimmy Carpenter (myself) is still the maintainer,
offer to take over!
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Geo/Horizon.pm view on Meta::CPAN
return $self->{'ellipsoid'};
}
=head2 distance
The straight-line of sight distance to the horizon: This formula does not take in account radio or optical refraction which will be further the longer the wavelength.
my $dist=$obj->distance($alt, $lat); #alt in meters (ellipsoid units)
#lat in signed decimal degrees
my $dist=$obj->distance($alt); #default lat => 0 (equator)
my $dist=$obj->distance; #default alt => 1.7
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Geo/Index.pm view on Meta::CPAN
print "$$closest{name}\n"; # Also prints 'South Pole'
($farthest) = $index->Farthest( [ 90, 0 ] );
print "$$farthest{name}\n"; # Also prints 'South Pole'
# Compute distance in meters between two points (using haversine formula)
$m = $index->Distance( { lat=>51.507222, lon=>-0.1275 }, [ -6.2, 106.816667 ] );
printf("London to Jakarta: %i km\n", $m / 1000);
$index->DistanceFrom( [ 90, 0 ] );
lib/Geo/Index.pm view on Meta::CPAN
circumference assuming a spherical (not an oblate) body.
=item *
B<C<search_result_distance>> - Distance (in meters) of point from search
point of previous search. The distance computation assumes a spherical body
and is computed using a ruggedized version of the haversine formula. This
value is only generated when C<L<Search(...)|/Search( ... )>> is called with the C<radius>
or C<sort_results> option. See also C<L<Distance(...)|/Distance( ... )>>, C<L<DistanceFrom(...)|/DistanceFrom( ... )>>,
and C<L<DistanceTo(...)|/DistanceTo( ... )>>.
=item *
B<C<antipode_distance>> - Distance (in meters) of point from search
point's antipode as determined by a previous call to C<L<Farthest(...)|/Farthest( ... )>>.
This distance is computed using a ruggedized version of the haversine formula.
=back
As a convenience, most methods allow points to be specified using a shorthand
notation S<C<[ I<lat>, I<lon> ]>> or S<C<[ I<lat>, I<lon>, I<data> ]>>. Points
lib/Geo/Index.pm view on Meta::CPAN
#. Distance functions
#.
#. Geo::Index uses the haversine formula to compute great circle distances
#. between points.
#.
#. Three versions are supported: a fallback version written in Perl (used if the
#. C versions fail to compile) and two accelerated versions written in C, one
#. using floats and the other using doubles. By default the C float version is
lib/Geo/Index.pm view on Meta::CPAN
( $sin_lon_diff_over_2 * $sin_lon_diff_over_2 )
* $DistanceFrom_cos_lat_1
* cos( $lat_0 )
);
#. The haversine formula may get messy around antipodal points so clip to the largest sane value.
if ( $n < 0.0 ) { $n = 0.0; }
return $DistanceFrom_diameter * asin( sqrt($n) );
}
lib/Geo/Index.pm view on Meta::CPAN
is not done then the distance values from the first search may be overwritten by
those of the subsequent searches.
=item *
Geo::Index uses the spherical haversine formula to compute distances. While
quite fast, its accuracy over long distances is poor, with a worst case error
of about 0.1% (22 km). Since the module already has provision for changing the
backends used for the distance methods, adding a new backend to, for example,
compute accurate distances on e.g. a WGS-84 spheroid would be simple and
straight-forward.
view all matches for this distribution
view release on metacpan or search on metacpan
will fail on.
* Calculate Heat Index and/or Wind Chill
Both would be fairly easy to do, provided you get the formulas
correct. (Those vary around the world!)
If you'd like to submit a patch for any of these, please let me know!
Please put 'METAR' in the subject of your e-mail.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Geo/MedianCenter/XS.pm view on Meta::CPAN
longitude in decimal degrees.
=item haversine_distance_dec($lat1, $lon1, $lat2, $long2)
Computes the distance between the two points using the Haversine
formula in meters. Latitude and longitude are specified in decimal
degrees.
=item haversine_distance_rad($lat1, $lon1, $lat2, $long2)
Computes the distance between the two points using the Haversine
formula in meters. Latitude and longitude are specified in radians.
=back
=head2 EXPORT
view all matches for this distribution
view release on metacpan or search on metacpan
longitude are the same. This only holds true at the equator;
otherwise the distance between two degrees longitude is:
cos($lat*PI/180)*LON_MILEAGE_CONSTANT
This formula is probably well-known, but I got it from:
http://www.malaysiagis.com/related_technologies/mapping/basics1b.cfm
This corrected a bug where the cells searched would often miss
areas that were a ways away from the site.
view all matches for this distribution
view release on metacpan or search on metacpan
longitude are the same. This only holds true at the equator;
otherwise the distance between two degrees longitude is:
cos($lat*PI/180)*LON_MILEAGE_CONSTANT
This formula is probably well-known, but I got it from:
http://www.malaysiagis.com/related_technologies/mapping/basics1b.cfm
This corrected a bug where the cells searched would often miss
areas that were a ways away from the site.
view all matches for this distribution
view release on metacpan or search on metacpan
Revision history for Perl extension Geo::Query.
0.04 08 Jul 2010
- Fixed distance formula for southern hemisphere
0.03 Mon Feb 11 07:42:42 CET 2008
- Calculates distances.
view all matches for this distribution
view release on metacpan or search on metacpan
This program was developed to be able to calculate the position between two GPS fixes using a 2-dimensional 3rd order polynomial spline.
f(t) = A + B(t-t0) + C(t-t0)^2 + D(t-t0)^3 #position in X and Y
f'(t) = B + 2C(t-t0) + 3D(t-t0)^2 #velocity in X and Y
I did some simple Math (for an engineer with a math minor) to come up with these formulas to calculate the unknowns from our knowns.
A = x0 # when (t-t0)=0 in f(t)
B = v0 # when (t-t0)=0 in f'(t)
C = (x1-A-B(t1-t0)-D(t1-t0)^3)/(t1-t0)^2 # solve for C from f(t)
C = (v1-B-3D(t1-t0)^2)/2(t1-t0) # solve for C from f'(t)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Geo/WeatherNWS.pm view on Meta::CPAN
$Report->{windchill_f} # Wind Chill (degrees f)
$Report->{windchill_c} # Wind Chill (degrees c)
$Report->{heat_index_f} # Heat Index (degrees f)
$Report->{heat_index_c} # Heat Index (degrees c)
Note: Due to the formulas used to get the heat index and windchill,
sometimes these values are a little strange. A check to see if the
heat index is above the temperature before displaying it would be
a good thing for you to do. You probably don't want to display
the windchill unless its cold either.
view all matches for this distribution
view release on metacpan or search on metacpan
maxmind-db/MaxMind-DB-spec.md view on Meta::CPAN
This key is optional. However, creators of databases are strongly
encouraged to include a description in at least one language.
### Calculating the Search Tree Section Size
The formula for calculating the search tree section size *in bytes* is as
follows:
( ( $record_size * 2 ) / 8 ) * $number_of_nodes
The end of the search tree marks the beginning of the data section.
maxmind-db/MaxMind-DB-spec.md view on Meta::CPAN
then it is an actual pointer value pointing into the data section. The value
of the pointer is relative to the start of the data section, *not* the
start of the file.
In order to determine where in the data section we should start looking, we use
the following formula:
$data_section_offset = ( $record_value - $node_count ) - 16
The 16 is the size of the data section separator. We subtract it because we
want to permit pointing to the first byte of the data section. Recall that
maxmind-db/MaxMind-DB-spec.md view on Meta::CPAN
is a *node number*, and we look up that node. If a record contains a value
greater than or equal to 1,016, we know that it is a data section value. We
subtract the node count (1,000) and then subtract 16 for the data section
separator, giving us the number 0, the first byte of the data section.
If a record contained the value 6,000, this formula would give us an offset of
4,984 into the data section.
In order to determine where in the file this offset really points to, we also
need to know where the data section starts. This can be calculated by
determining the size of the search tree in bytes and then adding an additional
maxmind-db/MaxMind-DB-spec.md view on Meta::CPAN
$offset_in_file = $data_section_offset
+ $search_tree_size_in_bytes
+ 16
Since we subtract and then add 16, the final formula to determine the
offset in the file can be simplified to:
$offset_in_file = ( $record_value - $node_count )
+ $search_tree_size_in_bytes
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Geography/NationalGrid/TW.pm view on Meta::CPAN
Returns the item from the Userdata hash whose key is the PARAMETER_NAME.
=item transform( PROJECTION )
Transform the point to the new projection, i.e. TWD67 to TWD97 or reverse. Return the point after transformation and keep original point intact. Uses the formula proposed by John Hsieh which is supposed to provide 2 meter accuracy conversions.
=back
=head1 ACCURACY AND PRECISION
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Geometry/Formula.pm view on Meta::CPAN
sub circle {
my ( $self, %param, $x ) = @_;
_param_check( 'circle', %param );
if ( $param{'formula'} eq 'area' ) {
$x = $PI * $self->_squared( $param{'radius'} );
}
elsif ( $param{'formula'} eq 'circumference' ) {
$x = ( 2 * $PI ) * $param{'radius'};
}
else {
$x = $param{'radius'} * 2;
}
lib/Geometry/Formula.pm view on Meta::CPAN
sub cube {
my ( $self, %param, $x ) = @_;
_param_check( 'cube', %param );
if ( $param{'formula'} eq 'surface_area' ) {
$x = 6 * ( $param{'a'} * 2 );
}
else {
$x = $self->_cubed( $param{'a'} );
}
lib/Geometry/Formula.pm view on Meta::CPAN
sub ellipse {
my ( $self, %param, $x ) = @_;
_param_check( 'ellipse', %param );
if ( $param{'formula'} eq 'area' ) {
$x = $PI * ( $param{'a'} * $param{'b'} );
}
else {
$x = 2 * $PI *
sqrt( ( $self->_squared( $param{'a'} ) + $self->_squared( $param{'b'} ) ) / 2 );
lib/Geometry/Formula.pm view on Meta::CPAN
sub frustum_of_right_circular_cone {
my ( $self, %param, $x ) = @_;
_param_check( 'frustum_of_right_circular_cone', %param );
if ( $param{'formula'} eq 'lateral_surface_area' ) {
$x =
$PI *
( $param{'large_radius'} + $param{'small_radius'} ) *
sqrt( $self->_squared( $param{'large_radius'} - $param{'small_radius'} ) +
$self->_squared( $param{'slant_height'} ) );
}
elsif ( $param{'formula'} eq 'total_surface_area' ) {
my $slant_height =
sqrt( $self->_squared( $param{'large_radius'} - $param{'small_radius'} ) +
$self->_squared( $param{'height'} ) );
$x =
lib/Geometry/Formula.pm view on Meta::CPAN
sub parallelogram {
my ( $self, %param, $x ) = @_;
_param_check( 'parallelogram', %param );
if ( $param{'formula'} eq 'area' ) {
$x = $param{'base'} * $param{'height'};
}
else {
$x = ( 2 * $param{'a'} ) + ( 2 * $param{'b'} );
}
lib/Geometry/Formula.pm view on Meta::CPAN
sub rectangle {
my ( $self, %param, $x ) = @_;
_param_check( 'rectangle', %param );
if ( $param{'formula'} eq 'area' ) {
$x = $param{'length'} * $param{'width'};
}
else {
$x = ( 2 * $param{'length'} ) + ( 2 * $param{'width'} );
}
lib/Geometry/Formula.pm view on Meta::CPAN
sub rectangular_solid {
my ( $self, %param, $x ) = @_;
_param_check( 'rectangular_solid', %param );
if ( $param{'formula'} eq 'volume' ) {
$x = $param{'length'} * $param{'width'} * $param{'height'};
}
else {
$x =
2 *
lib/Geometry/Formula.pm view on Meta::CPAN
sub right_circular_cone {
my ( $self, %param, $x ) = @_;
_param_check( 'right_circular_cone', %param );
if ( $param{'formula'} eq 'lateral_surface_area' ) {
$x =
$PI *
$param{'radius'} *
( sqrt( $self->_squared( $param{'radius'} ) + $self->_squared( $param{'height'} ) ) );
}
lib/Geometry/Formula.pm view on Meta::CPAN
sub right_circular_cylinder {
my ( $self, %param, $x ) = @_;
_param_check( 'right_circular_cylinder', %param );
if ( $param{'formula'} eq 'lateral_surface_area' ) {
$x = 2 * $PI * $param{'radius'} * $param{'height'};
}
elsif ( $param{'formula'} eq 'total_surface_area' ) {
$x =
2 * $PI * $param{'radius'} * ( $param{'radius'} + $param{'height'} );
}
else {
$x = $PI * ( $self->_squared( $param{'radius'} ) * $param{'height'} );
lib/Geometry/Formula.pm view on Meta::CPAN
sub sphere {
my ( $self, %param, $x ) = @_;
_param_check( 'sphere', %param );
if ( $param{'formula'} eq 'surface_area' ) {
$x = 4 * $PI * $self->_squared( $param{'radius'} );
}
else {
$x = ( 4 / 3 ) * $PI * $self->_cubed( $param{'radius'} );
}
lib/Geometry/Formula.pm view on Meta::CPAN
sub square {
my ( $self, %param, $x ) = @_;
_param_check( 'square', %param );
if ( $param{'formula'} eq 'area' ) {
$x = $self->_squared( $param{'side'} );
}
else {
$x = $param{'side'} * 4;
}
lib/Geometry/Formula.pm view on Meta::CPAN
sub torus {
my ( $self, %param, $x ) = @_;
_param_check( 'torus', %param );
if ( $param{'formula'} eq 'surface_area' ) {
$x = 4 * $self->_squared($PI) * $param{'a'} * $param{'b'};
}
else {
$x = 2 * $self->_squared($PI) * $self->_squared( $param{'a'} ) * $param{'b'};
}
lib/Geometry/Formula.pm view on Meta::CPAN
sub trapezoid {
my ( $self, %param, $x ) = @_;
_param_check( 'trapezoid', %param );
if ( $param{'formula'} eq 'area' ) {
$x = ( ( $param{'a'} + $param{'b'} ) / 2 ) * $param{'height'};
}
else {
$x = $param{'a'} + $param{'b'} + $param{'c'} + $param{'d'};
}
lib/Geometry/Formula.pm view on Meta::CPAN
sub triangle {
my ( $self, %param, $x ) = @_;
_param_check( 'triangle', %param );
if ( $param{'formula'} eq 'area' ) {
$x = .5 * $param{'base'} * $param{'height'};
}
else {
$x = $param{'a'} + $param{'b'} + $param{'c'};
}
lib/Geometry/Formula.pm view on Meta::CPAN
perimeter => [ 'a', 'b', 'c' ]
},
);
# validate that parameter values are defined and numeric
foreach ( @{ $valid_params{$method}{ $param{'formula'} } } ) {
croak "required parameter '$_' not defined"
if !$param{$_};
croak "parameter '$_' requires a numeric value"
if $param{$_} !~ m/^\d+$/;
}
# validate parameter is a valid constructor/component of formula
foreach my $param ( keys %param ) {
next if $param eq 'formula';
my @constructors = @{ $valid_params{$method}{ $param{'formula'} } };
if ( !@constructors ) {
croak "invalid formula name: $param{'formula'} specified";
}
if ( grep { $_ eq $param } @constructors ) {
next;
}
lib/Geometry/Formula.pm view on Meta::CPAN
=pod
=head1 NAME
Geometry::Formula - methods to calculate common geometry formulas.
=head1 VERSION
Version 0.01
lib/Geometry/Formula.pm view on Meta::CPAN
my $x = Geometry::Formula->new;
=head1 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.
=head1 CONSTRUCTOR
=over
=item C<< new() >>
Returns a reference to a new formula object. No arguments currently needed
or required.
=back
=head1 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
=over
=item C<< 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.
=item C<< 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
);
=item C<< cone() >>
The cone method provides a volume formula.
required: base, height
$x->cone(
formula => 'volume',
base => int,
height => int
);
=item C<< 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
);
=item C<< 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
=item C<< 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
=item C<< equilateral_triangle() >>
The equalateral_triangle method provides an area formula.
required: side
x->equilateral_triangle(
formula => 'area',
side => int,
);
=item C<< 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
);
=item C<< 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
=item C<< 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
);
=item C<< 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
);
=item C<< 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)
=item C<< 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
);
=item C<< 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
);
=item C<< 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).
=item C<< 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
);
=item C<< square() >>
The square method provides an area and perimeter formula.
required: side
$x->square(
formula => 'area',
side => int
);
$x->square(
formula => 'perimeter',
side => int
);
=item C<< 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
=item C<< 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
);
=item C<< 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
);
lib/Geometry/Formula.pm view on Meta::CPAN
numeric values passed to this fucntion get$self->_cubed and returned
=item C<< _param_check( $name_of_method, %param ) >>
this method validates the parameters being passed into our formula methods
are properly constructed.
=back
=head1 DIAGNOSTICS
view all matches for this distribution
view release on metacpan or search on metacpan
deps/libgit2/README.md view on Meta::CPAN
an application in C - then you may be able use an existing binary.
There are packages for the
[vcpkg](https://github.com/Microsoft/vcpkg) and
[conan](https://conan.io/center/libgit2)
package managers. And libgit2 is available in
[Homebrew](https://formulae.brew.sh/formula/libgit2) and most Linux
distributions.
However, these versions _may_ be outdated and we recommend using the
latest version if possible. Thankfully libgit2 is not hard to compile.
view all matches for this distribution
view release on metacpan or search on metacpan
xs/libgit2/deps/zlib/adler32.c view on Meta::CPAN
{
unsigned long sum1;
unsigned long sum2;
unsigned rem;
/* the derivation of this formula is left as an exercise for the reader */
rem = (unsigned)(len2 % BASE);
sum1 = adler1 & 0xffff;
sum2 = rem * sum1;
MOD(sum2);
sum1 += (adler2 & 0xffff) + BASE - 1;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Google/RestApi/SheetsApi4/Range.pm view on Meta::CPAN
my %p = @_;
# if a range is included, assume this cache is coming from the api as a reply.
# this is to store the values for this range when includeValuesInResponse is
# added to the url or content on the original values call. you can replace the
# original values using the valueRenderOption to replace, say, formulas with their
# calculated value.
if ($p{range}) {
state $check = compile_named(
majorDimension => DimColRow,
range => StrMatch[qr/.+!/],
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Graph/Graph6.pm view on Meta::CPAN
self-loops but no multi-edges.
=cut
# GP-DEFINE graph6_size_bits_by_sum(n) = sum(j=1,n-1, sum(i=0, j-1, 1));
# GP-DEFINE graph6_size_bits_formula(n) = n*(n-1)/2;
# GP-Test vector(100,n, graph6_size_bits_formula(n)) == \
# GP-Test vector(100,n, graph6_size_bits_by_sum(n))
# GP-DEFINE graph6_size_bits_formula(n) = n^2/2 - n/2;
# GP-Test vector(100,n, graph6_size_bits_formula(n)) == \
# GP-Test vector(100,n, graph6_size_bits_by_sum(n))
=pod
This module reads and writes in a "native" way as integer vertex numbers 0
view all matches for this distribution
view release on metacpan or search on metacpan
devel/Hanoi-equal-shortest.pl view on Meta::CPAN
# GP-DEFINE read("OEIS-data.gp");
# GP-DEFINE read("OEIS-data-wip.gp");
# GP-DEFINE OEIS_check_verbose = 1;
# GP-DEFINE A107839_formula(n) = \
# GP-DEFINE polcoeff(lift(Mod('x,'x^2-5*'x+2)^(n+1)),1);
# GP-DEFINE A107839(n) = {
# GP-DEFINE n>=0 || error("A107839() is for n>=0");
# GP-DEFINE A107839_formula(n);
# GP-DEFINE }
# GP-Test OEIS_check_func("A107839")
# OEIS_check_func("A107839",'bfile)
# GP-DEFINE A052984_formula(n) = vecsum(Vec(lift(Mod('x,'x^2-5*'x+2)^(n+1))));
# GP-DEFINE A052984(n) = {
# GP-DEFINE n>=0 || error("A052984() is for n>=0");
# GP-DEFINE A052984_formula(n);
# GP-DEFINE }
# GP-Test OEIS_check_func("A052984")
# OEIS_check_func("A052984",,'bfile)
# my(v=OEIS_data("A052984")); \
devel/Hanoi-equal-shortest.pl view on Meta::CPAN
# not in OEIS: 0.438447187191
# GP-Test PM_poly(M) == 0
# GP-Test P*M == 2
#---
# GP-DEFINE \\ powers formula by Hinz et al, x_n for n+1 discs
# GP-DEFINE xx(n) = {
# GP-DEFINE simplify(
# GP-DEFINE 3/(4*sqrt17)
# GP-DEFINE * ((sqrt17+1)*P^(n+1) - 2*3^(n+1)*sqrt17 + (sqrt17-1)*M^(n+1))
# GP-DEFINE );
# GP-DEFINE }
# GP-Test /* in x_n, A107839 across one pair n within n+1 */ \
# GP-Test vector(10,n,n--; (xx(n+1) - 3*xx(n))/6) == \
# GP-Test vector(10,n,n--; A107839(n))
#
# GP-DEFINE a_formula(n) = xx(n-1);
# GP-DEFINE a(n) = {
# GP-DEFINE n>=1 || error("a() is for n>=1");
# GP-DEFINE xx(n-1);
# GP-DEFINE }
# GP-Test vector(4,n, a(n)) == [0, 6, 48, 282]
devel/Hanoi-equal-shortest.pl view on Meta::CPAN
# GP-Test /* subgraphs using A107839 = num between subgraphs */ \
# GP-Test vector(100,n,n++; a(n)) == \
# GP-Test vector(100,n,n++; 3*a(n-1) + 6*A107839(n-2))
#
# GP-Test my(n=1); a(n) == 0
# GP-Test my(n=1); 6*A107839_formula(n-2) == 0
# GP-Test my(n=0); a_formula(n) == 0
# GP-Test my(n=0); 6*A107839_formula(n-2) == -3
# GP-Test my(n=-1); a_formula(n) == 1
# GP-Test /* including reversing back earlier */ \
# GP-Test vector(100,n,n-=20; a_formula(n)) == \
# GP-Test vector(100,n,n-=20; 3*a_formula(n-1) + 6*A107839_formula(n-2))
# GP-Test my(n=3); A107839_formula(n-2) == 5 /* my n=3 example */
#
# GP-Test /* recurrence 8, -17, 6
# GP-Test vector(100,n,n+=2; a(n)) == \
# GP-Test vector(100,n,n+=2; 8*a(n-1) - 17*a(n-2) + 6*a(n-3))
# GP-Test vector(100,n,n-=20; a_formula(n)) == \
# GP-Test vector(100,n,n-=20; \
# GP-Test 8*a_formula(n-1) - 17*a_formula(n-2) + 6*a_formula(n-3))
#
# GP-Test /* using A052984 for the Lucas sequence part */ \
# GP-Test vector(100,n, a(n)) == \
# GP-Test vector(100,n, (A052984(n) - 3^n)*3/2 )
devel/Hanoi-equal-shortest.pl view on Meta::CPAN
# GP-DEFINE \\ compact polmod
# GP-DEFINE my(p=Mod('x, 'x^2-5*'x+2)); a_compact(n) = (vecsum(Vec(lift(p^(n+1)))) - 3^n)*3/2;
# GP-Test vector(100,n, a(n)) == \
# GP-Test vector(100,n, a_compact(n))
# GP-Test vector(100,n,n-=20; a_formula(n)) == \
# GP-Test vector(100,n,n-=20; a_compact(n))
# GP-Test 6*5 + 6*3*1 == 48
# GP-Test /* A107839 across one pair n when making n+1 */ \
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Graphics/ColorNames/PantoneReport.pm view on Meta::CPAN
mistaken for the colors of the palette created by Pantone for Designers,
which can be accessed via L<Graphics::ColorNames::Pantone>. I choose
TPX (TPG) over TCX values since ladder are specific to the textile industry
and I assume usage of this module is monitor related. However, when no
TPX (TPG) available we took TCX, since I dont have the exact conversion
formula.
All names are lower case and do not contain space or apostrophes or other
none ASCII characters - the originally named C<"Potter's Clay"> is
here C<"pottersclay"> and C<'Crème de Peche'> => C<'cremedepeche'>.
But you can actually access them as "Potters_Clay" and 'Creme_de_Peche'
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Graphics/Framebuffer.pm view on Meta::CPAN
sub monochrome {
=head2 monochrome
Removes all color information from an image, and leaves everything in greyscale.
It applies the following formula to calculate greyscale:
grey_color = (red * 0.2126) + (green * 0.7155) + (blue * 0.0722)
=over 4
view all matches for this distribution
view release on metacpan or search on metacpan
include/libmng.h view on Meta::CPAN
MNG_EXT mng_retcode MNG_DECL mng_set_srgbimplicit (mng_handle hHandle);
#endif
/* Gamma settings */
/* only used if you #define MNG_FULL_CMS or #define MNG_GAMMA_ONLY */
/* ... blabla (explain gamma processing a little; eg. formula & stuff) ... */
MNG_EXT mng_retcode MNG_DECL mng_set_viewgamma (mng_handle hHandle,
mng_float dGamma);
MNG_EXT mng_retcode MNG_DECL mng_set_displaygamma (mng_handle hHandle,
mng_float dGamma);
MNG_EXT mng_retcode MNG_DECL mng_set_dfltimggamma (mng_handle hHandle,
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Grid/Request.pm view on Meta::CPAN
# Iterate over them...
my $command_count = 1;
eval { require Grid::Request::JobFormulator };
my $formulator = Grid::Request::JobFormulator->new();
foreach my $com_obj (@command_objs) {
print "Command #" . $command_count . "\n";
my $exe = $com_obj->command();
my $block_size = $com_obj->block_size();
lib/Grid/Request.pm view on Meta::CPAN
foreach my $param_obj (@params) {
my $param_str = $param_obj->to_string();
push (@param_strings, $param_str);
}
my @invocations = $formulator->formulate($block_size, $exe, @param_strings);
foreach my $invocations (@invocations) {
my @cli = @$invocations;
my @esc_cli = _esc_chars(@cli);
print join(" ", @esc_cli) . "\n";
}
view all matches for this distribution
view release on metacpan or search on metacpan
docs/assets/stylesheets/bootstrap/_glyphicons.scss view on Meta::CPAN
.glyphicon-king { &:before { content: "\e211"; } }
.glyphicon-queen { &:before { content: "\e212"; } }
.glyphicon-pawn { &:before { content: "\e213"; } }
.glyphicon-bishop { &:before { content: "\e214"; } }
.glyphicon-knight { &:before { content: "\e215"; } }
.glyphicon-baby-formula { &:before { content: "\e216"; } }
.glyphicon-tent { &:before { content: "\26fa"; } }
.glyphicon-blackboard { &:before { content: "\e218"; } }
.glyphicon-bed { &:before { content: "\e219"; } }
.glyphicon-apple { &:before { content: "\f8ff"; } }
.glyphicon-erase { &:before { content: "\e221"; } }
view all matches for this distribution