.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" 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 turned on, 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 .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Math::Polygon 3pm" .TH Math::Polygon 3pm "2014-01-21" "perl v5.18.2" "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" Math::Polygon \- Class for maintaining polygon data .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& my $poly = Math::Polygon\->new( [1,2], [2,4], [5,7], [1,2] ); \& print $poly\->nrPoints; \& my @p = $poly\->points; \& \& my ($xmin, $ymin, $xmax, $ymax) = $poly\->bbox; \& \& my $area = $poly\->area; \& my $l = $poly\->perimeter; \& if($poly\->isClockwise) { ... }; \& \& my $rot = $poly\->startMinXY; \& my $center = $poly\->centroid; \& if($poly\->contains($point)) { ... }; \& \& my $boxed = $poly\->lineClip($xmin, $xmax, $ymin, $ymax); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This class provides an \s-1OO\s0 interface around Math::Polygon::Calc and Math::Polygon::Clip. .SH "METHODS" .IX Header "METHODS" .SS "Constructors" .IX Subsection "Constructors" .ie n .IP "$obj\->\fBnew\fR([%options], [$points], [%options])" 4 .el .IP "\f(CW$obj\fR\->\fBnew\fR([%options], [$points], [%options])" 4 .IX Item "$obj->new([%options], [$points], [%options])" .PD 0 .IP "Math::Polygon\->\fBnew\fR([%options], [$points], [%options])" 4 .IX Item "Math::Polygon->new([%options], [$points], [%options])" .PD You may add \f(CW%options\fR after and/or before the \f(CW$points\fR. You may also use the \*(L"points\*(R" options to get the points listed. \f(CW$points\fR are references to an \s-1ARRAY\s0 of X and Y. .Sp When \f(CW\*(C`new\*(C'\fR is called as instance method, it is believed that the new polygon is derived from the callee, and therefore some facts (like clockwise or anti-clockwise direction) will get copied unless overruled. .Sp .Vb 4 \& \-Option \-\-Default \& bbox undef \& clockwise undef \& points undef .Ve .RS 4 .IP "bbox => \s-1ARRAY\s0" 2 .IX Item "bbox => ARRAY" Usually computed from the figure automatically, but can also be specified as [xmin,ymin,xmax, ymax]. See \fIbbox()\fR. .IP "clockwise => \s-1BOOLEAN\s0" 2 .IX Item "clockwise => BOOLEAN" Is not specified, it will be computed by the \fIisClockwise()\fR method on demand. .IP "points => ARRAY-of-POINTS" 2 .IX Item "points => ARRAY-of-POINTS" See \fIpoints()\fR and \fInrPoints()\fR. .RE .RS 4 .Sp example: creation of new polygon .Sp .Vb 1 \& my $p = Math::Polygon\->new([1,0],[1,1],[0,1],[0,0],[1,0]); \& \& my @p = ([1,0],[1,1],[0,1],[0,0],[1,0]); \& my $p = Math::Polygon\->new(points => \e@p); .Ve .RE .SS "Attributes" .IX Subsection "Attributes" .ie n .IP "$obj\->\fBnrPoints\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBnrPoints\fR()" 4 .IX Item "$obj->nrPoints()" Returns the number of points, .ie n .IP "$obj\->\fBorder\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBorder\fR()" 4 .IX Item "$obj->order()" Returns the number of uniqe points: one less than \fInrPoints()\fR. .ie n .IP "$obj\->\fBpoint\fR($index, [$index,...])" 4 .el .IP "\f(CW$obj\fR\->\fBpoint\fR($index, [$index,...])" 4 .IX Item "$obj->point($index, [$index,...])" Returns the point with the specified \f(CW$index\fR or \s-1INDEXES. \s0 In \s-1SCALAR\s0 context, only the first \f(CW$index\fR is used. .Sp example: .Sp .Vb 2 \& my $point = $poly\->point(2); \& my ($first, $last) = $poly\->point(0, \-1); .Ve .ie n .IP "$obj\->\fBpoints\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBpoints\fR()" 4 .IX Item "$obj->points()" In \s-1LIST\s0 context, the points are returned as list, otherwise as reference to an \s-1ARRAY.\s0 .Sp example: .Sp .Vb 4 \& my @points = $poly\->points; \& my $first = $points[0]; \& my $x0 = $points[0][0]; # $first\->[0] \& my $y0 = $points[0][1]; # $first\->[1] .Ve .SS "Geometry" .IX Subsection "Geometry" .ie n .IP "$obj\->\fBarea\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBarea\fR()" 4 .IX Item "$obj->area()" Returns the area enclosed by the polygon. The last point of the list must be the same as the first to produce a correct result. The computed result is cached. Function \fIMath::Polygon::Calc::polygon_area()\fR. .Sp example: .Sp .Vb 2 \& my $area = $poly\->area; \& print "$area $poly_units ^2\en"; .Ve .ie n .IP "$obj\->\fBbbox\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBbbox\fR()" 4 .IX Item "$obj->bbox()" Returns a list with four elements: (xmin, ymin, xmax, ymax), which describe the bounding box of the polygon (all points of the polygon are inside that area). The computation is expensive, and therefore, the results are cached. Function \fIMath::Polygon::Calc::polygon_bbox()\fR. .Sp example: .Sp .Vb 1 \& my ($xmin, $ymin, $xmax, $ymax) = $poly\->bbox; .Ve .ie n .IP "$obj\->\fBbeautify\fR(%options)" 4 .el .IP "\f(CW$obj\fR\->\fBbeautify\fR(%options)" 4 .IX Item "$obj->beautify(%options)" Returns a new, beautified version of this polygon. Function \fIMath::Polygon::Calc::polygon_beautify()\fR. .Sp Polygons, certainly after some computations, can have a lot of horrible artifacts: points which are double, spikes, etc. This functions provided by this module beautify .Sp .Vb 2 \& \-Option \-\-Default \& remove_spikes .Ve .RS 4 .IP "remove_spikes => \s-1BOOLEAN\s0" 2 .IX Item "remove_spikes => BOOLEAN" .RE .RS 4 .RE .PD 0 .ie n .IP "$obj\->\fBcentroid\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBcentroid\fR()" 4 .IX Item "$obj->centroid()" .PD Returns the centroid location of the polygon. The last point of the list must be the same as the first to produce a correct result. The computed result is cached. Function \fIMath::Polygon::Calc::polygon_centroid()\fR. .Sp example: .Sp .Vb 2 \& my $center = $poly\->centroid; \& my ($cx, $cy) = @$center; .Ve .ie n .IP "$obj\->\fBclockwise\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBclockwise\fR()" 4 .IX Item "$obj->clockwise()" Make sure the points are in clockwise order. .Sp example: .Sp .Vb 1 \& $poly\->clockwise; .Ve .ie n .IP "$obj\->\fBcontains\fR($point)" 4 .el .IP "\f(CW$obj\fR\->\fBcontains\fR($point)" 4 .IX Item "$obj->contains($point)" Returns a truth value indicating whether the point is inside the polygon or not. On the edge is inside. .ie n .IP "$obj\->\fBcounterClockwise\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBcounterClockwise\fR()" 4 .IX Item "$obj->counterClockwise()" Make sure the points are in counter-clockwise order. .Sp example: .Sp .Vb 1 \& $poly\->counterClockwise .Ve .ie n .IP "$obj\->\fBequal\fR(<$other | \s-1ARRAY\s0,[$tolerance]> | $points)" 4 .el .IP "\f(CW$obj\fR\->\fBequal\fR(<$other | \s-1ARRAY\s0,[$tolerance]> | \f(CW$points\fR)" 4 .IX Item "$obj->equal(<$other | ARRAY,[$tolerance]> | $points)" Compare two polygons, on the level of points. When the polygons are the same but rotated, this will return false. See \fIsame()\fR. Function \fIMath::Polygon::Calc::polygon_equal()\fR. .ie n .IP "$obj\->\fBisClockwise\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBisClockwise\fR()" 4 .IX Item "$obj->isClockwise()" The points are (in majority) orded in the direction of the hands of the clock. This calculation is quite expensive (same effort as calculating the area of the polygon), and the result is therefore cached. .Sp example: .Sp .Vb 1 \& if($poly\->isClockwise) ... .Ve .ie n .IP "$obj\->\fBisClosed\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBisClosed\fR()" 4 .IX Item "$obj->isClosed()" Returns true if the first point of the poly definition is the same as the last point. .ie n .IP "$obj\->\fBperimeter\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBperimeter\fR()" 4 .IX Item "$obj->perimeter()" The length of the line of the polygon. This can also be used to compute the length of any line: of the last point is not equal to the first, then a line is presumed; for a polygon they must match. Function \fIMath::Polygon::Calc::polygon_perimeter()\fR. .Sp example: .Sp .Vb 2 \& my $fence = $poly\->perimeter; \& print "fence length: $fence $poly_units\en" .Ve .ie n .IP "$obj\->\fBsame\fR(<$other | \s-1ARRAY\s0,[$tolerance]> | $points)" 4 .el .IP "\f(CW$obj\fR\->\fBsame\fR(<$other | \s-1ARRAY\s0,[$tolerance]> | \f(CW$points\fR)" 4 .IX Item "$obj->same(<$other | ARRAY,[$tolerance]> | $points)" Compare two polygons, where the polygons may be rotated wrt each other. This is (much) slower than \fIequal()\fR, but some algorithms will cause un unpredictable rotation in the result. Function \fIMath::Polygon::Calc::polygon_same()\fR. .ie n .IP "$obj\->\fBstartMinXY\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBstartMinXY\fR()" 4 .IX Item "$obj->startMinXY()" Returns a new polygon object, where the points are rotated in such a way that the point which is losest to the left-bottom point of the bouding box has become the first. .Sp Function \fIMath::Polygon::Calc::polygon_start_minxy()\fR. .SS "Transformations" .IX Subsection "Transformations" Implemented in Math::Polygon::Transform: changes on the structure of the polygon except clipping. All functions return a new polygon object or undef. .ie n .IP "$obj\->\fBgrid\fR(%options)" 4 .el .IP "\f(CW$obj\fR\->\fBgrid\fR(%options)" 4 .IX Item "$obj->grid(%options)" Returns a polygon object with the points snapped to grid points. See \fIMath::Polygon::Transform::polygon_grid()\fR. .Sp .Vb 2 \& \-Option\-\-Default \& raster 1.0 .Ve .RS 4 .IP "raster => \s-1FLOAT\s0" 2 .IX Item "raster => FLOAT" The raster size, which determines the points to round to. The origin \&\f(CW\*(C`[0,0]\*(C'\fR is always on a grid-point. When the raster value is zero, no transformation will take place. .RE .RS 4 .RE .ie n .IP "$obj\->\fBmirror\fR(%options)" 4 .el .IP "\f(CW$obj\fR\->\fBmirror\fR(%options)" 4 .IX Item "$obj->mirror(%options)" Mirror the polygon in a line. Only one of the options can be provided. Some programs call this \*(L"flip\*(R" or \*(L"flop\*(R". .Sp .Vb 6 \& \-Option\-\-Default \& b 0 \& line \& rc undef \& x undef \& y undef .Ve .RS 4 .IP "b => \s-1FLOAT\s0" 2 .IX Item "b => FLOAT" Only used in combination with option \f(CW\*(C`rc\*(C'\fR to describe a line. .IP "line => [\s-1POINT, POINT\s0]" 2 .IX Item "line => [POINT, POINT]" Alternative way to specify the mirror line. The \f(CW\*(C`rc\*(C'\fR and \f(CW\*(C`b\*(C'\fR are computed from the two points of the line. .IP "rc => \s-1FLOAT\s0" 2 .IX Item "rc => FLOAT" Description of the line which is used to mirror in. The line is \&\f(CW\*(C`y= rc*x+b\*(C'\fR. The \f(CW\*(C`rc\*(C'\fR equals \f(CW\*(C`\-dy/dx\*(C'\fR, the firing angle. If \&\f(CW\*(C`undef\*(C'\fR is explicitly specified then \f(CW\*(C`b\*(C'\fR is used as constant x: it's a vertical mirror. .IP "x => \s-1FLOAT\s0" 2 .IX Item "x => FLOAT" Mirror in the line \f(CW\*(C`x=value\*(C'\fR, which means that \f(CW\*(C`y\*(C'\fR stays unchanged. .IP "y => \s-1FLOAT\s0" 2 .IX Item "y => FLOAT" Mirror in the line \f(CW\*(C`y=value\*(C'\fR, which means that \f(CW\*(C`x\*(C'\fR stays unchanged. .RE .RS 4 .RE .ie n .IP "$obj\->\fBmove\fR(%options)" 4 .el .IP "\f(CW$obj\fR\->\fBmove\fR(%options)" 4 .IX Item "$obj->move(%options)" Returns a moved polygon object: all point are moved over the indicated distance. See \fIMath::Polygon::Transform::polygon_move()\fR. .Sp .Vb 3 \& \-Option\-\-Default \& dx 0 \& dy 0 .Ve .RS 4 .IP "dx => \s-1FLOAT\s0" 2 .IX Item "dx => FLOAT" Displacement in the horizontal direction. .IP "dy => \s-1FLOAT\s0" 2 .IX Item "dy => FLOAT" Displacement in the vertical direction. .RE .RS 4 .RE .ie n .IP "$obj\->\fBresize\fR(%options)" 4 .el .IP "\f(CW$obj\fR\->\fBresize\fR(%options)" 4 .IX Item "$obj->resize(%options)" Returns a resized polygon object. See \fIMath::Polygon::Transform::polygon_resize()\fR. .Sp .Vb 5 \& \-Option\-\-Default \& center [0,0] \& scale 1.0 \& xscale \& yscale .Ve .RS 4 .IP "center => \s-1POINT\s0" 2 .IX Item "center => POINT" .PD 0 .IP "scale => \s-1FLOAT\s0" 2 .IX Item "scale => FLOAT" .PD Resize the polygon with the indicated factor. When the factor is larger than 1, the resulting polygon with grow, when small it will be reduced in size. The scale will be respective from the center. .IP "xscale => \s-1FLOAT\s0" 2 .IX Item "xscale => FLOAT" Specific scaling factor in the horizontal direction. .IP "yscale => \s-1FLOAT\s0" 2 .IX Item "yscale => FLOAT" Specific scaling factor in the vertical direction. .RE .RS 4 .RE .ie n .IP "$obj\->\fBrotate\fR(%options)" 4 .el .IP "\f(CW$obj\fR\->\fBrotate\fR(%options)" 4 .IX Item "$obj->rotate(%options)" Returns a rotated polygon object: all point are moved over the indicated distance. See \fIMath::Polygon::Transform::polygon_rotate()\fR. .Sp .Vb 4 \& \-Option \-\-Default \& center [0,0] \& degrees 0 \& radians 0 .Ve .RS 4 .IP "center => \s-1POINT\s0" 2 .IX Item "center => POINT" .PD 0 .IP "degrees => \s-1FLOAT\s0" 2 .IX Item "degrees => FLOAT" .PD specify rotation angle in degrees (between \-180 and 360). .IP "radians => \s-1FLOAT\s0" 2 .IX Item "radians => FLOAT" specify rotation angle in rads (between \-pi and 2*pi) .RE .RS 4 .RE .ie n .IP "$obj\->\fBsimplify\fR(%options)" 4 .el .IP "\f(CW$obj\fR\->\fBsimplify\fR(%options)" 4 .IX Item "$obj->simplify(%options)" Returns a polygon object where points are removed. See \fIMath::Polygon::Transform::polygon_simplify()\fR. .Sp .Vb 4 \& \-Option \-\-Default \& max_points undef \& same 0.0001 \& slope undef .Ve .RS 4 .IP "max_points => \s-1INTEGER\s0" 2 .IX Item "max_points => INTEGER" First, \f(CW\*(C`same\*(C'\fR and \f(CW\*(C`slope\*(C'\fR reduce the number of points. Then, if there are still more than the specified number of points left, the points with the widest angles will be removed until the specified maximum number is reached. .IP "same => \s-1FLOAT\s0" 2 .IX Item "same => FLOAT" The distance between two points to be considered \*(L"the same\*(R" point. The value is used as radius of the circle. .IP "slope => \s-1FLOAT\s0" 2 .IX Item "slope => FLOAT" With three points X(n),X(n+1),X(n+2), the point X(n+1) will be removed if the length of the path over all three points is less than \f(CW\*(C`slope\*(C'\fR longer than the direct path between X(n) and X(n+2). .Sp The slope will not be removed around the starting point of the polygon. Removing points will change the area of the polygon. .RE .RS 4 .RE .SS "Clipping" .IX Subsection "Clipping" .ie n .IP "$obj\->\fBfillClip1\fR($box)" 4 .el .IP "\f(CW$obj\fR\->\fBfillClip1\fR($box)" 4 .IX Item "$obj->fillClip1($box)" Clipping a polygon into rectangles can be done in various ways. With this algorithm, the parts of the polygon which are outside the \f(CW$box\fR are mapped on the borders. The polygon stays in one piece, but may have vertices which are followed in two directions. .Sp Returned is one polygon, which is cleaned from double points, spikes and superfluous intermediate points, or \f(CW\*(C`undef\*(C'\fR when no polygon is outside the \f(CW$box\fR. Function \fIMath::Polygon::Clip::polygon_fill_clip1()\fR. .ie n .IP "$obj\->\fBlineClip\fR($box)" 4 .el .IP "\f(CW$obj\fR\->\fBlineClip\fR($box)" 4 .IX Item "$obj->lineClip($box)" Returned is a list of ARRAYS-OF-POINTS containing line pieces from the input polygon. Function \fIMath::Polygon::Clip::polygon_line_clip()\fR. .SS "Display" .IX Subsection "Display" .ie n .IP "$obj\->\fBstring\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBstring\fR()" 4 .IX Item "$obj->string()" .SH "SEE ALSO" .IX Header "SEE ALSO" This module is part of Math-Polygon distribution version 1.03, built on January 21, 2014. Website: \fIhttp://perl.overmeer.net/geo/\fR .SH "LICENSE" .IX Header "LICENSE" Copyrights 2004,2006\-2014 by [Mark Overmeer]. For other contributors see ChangeLog. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See \fIhttp://www.perl.com/perl/misc/Artistic.html\fR