affiner 0.1.1
Initial features
-
affineGrob()andgrid.affine()provide wrappers aroundgrid::defineGrob()andgrid::useGrob()isocubeGrob()andgrid.isocube()provides a convenience wrapper for the isometric cube case.
-
affine_settings()computesgridaffine transformation feature viewports and transformation functions- Available as a "standalone" file that can be copied
over into other R packages under the permissive Unlicense.
- Available as a "standalone" file that can be copied
-
angle()creates angle vector S3 classes that allow users to use whichever angular unit is most convenient for them:-
Supports "degrees", "radians", "half-turns" (aka "pi-radians"), (full) "turns", and "gradians" units.
-
is_angle()tests whether the input is an angle vector. -
as_angle()casts objects to angle vectors. -
degrees(),gradians(),pi_radians(),radians(), andturns()are convenience wrappers around
as_angle()for those commonly used angular units. -
is_congruent()is a generic S3 method which tests whether two R objects are "congruent".
Theis_congruent()method for angle vectors tests whether two angles are congruent. -
angular_unit()can be used to get/set the angular unit of angle vectors. -
The default angular unit can be adjusted locally/globally by setting the "affiner_angular_unit" option.
e.g.options(affiner_angular_unit = "turns"). -
sine(),cosine(),tangent(),secant(),cosecant(),cotangent(),
arcsine(),arccosine(),arctangent(),arcsecant(),arccosecant(), andarccotangent()
are angle vector aware trigonometric functions. -
We implement methods for several base generics (plus as a numeric vector it inherits support for several more).
Some notes:- If both objects in a mathematical operation (in particular
+and-) or ac()combining operation
are angle vectors then we coerce the second one to use the same angular unit as the first one. as.numeric()takes aunitargument which can be used to convert angles into other angular units
e.g.angle(x, "degrees") |> as.numeric("radians")to cast a numeric vectorxfrom degrees to radians.abs()will calculate the angle modulo full turns.
- If both objects in a mathematical operation (in particular
-
-
Coord1D,Coord2D, andCoord3Dare (Cartesian) coordinate R6 classes-
is_coord1d(),is_coord2d(), andis_coord3d()test whether objects areCoord1D,Coord2D, orCoord3DR6 classes -
as_coord1d(),as_coord2d(), andas_coord3d()cast objects toCoord1D,Coord2D, orCoord3DR6 classes -
Several mathematical operations are supported for
Coord1D,Coord2D, orCoord3DR6 classes*either applies a "dot" product (if multiplying anotherCoord1D,Coord2D, orCoord3Dobject)
or a "scaling" transformation (if multiplying a numeric value)/applies a "scaling" transformation- Unary
-applies a "scaling" transformation whereas
binary-and+apply a "translation" transformation
-
Additional S3 methods:
abs()computes Euclidean normconvex_hull2d()computes convex hull (currently just forCoord2Dvectors)cross_product3d()computes a cross product betweenCoord3Dvectorsdistance1d(),distance2d(), anddistance3d()computes Euclidean distancesmean()computes centroids of coordinatesnormal2d()computesCoord2Dnormalsnormal3d()computesCoord3Dnormalsplot()andpoints()plotsCoord1DandCoord2Dcoordinates using base graphics.
If the suggested{ggplot2}package is installed one may also useautolayer()
to plotCoord1DandCoord2Dpoints.
If the suggested{rgl}package is installed one may also useplot3d()to
plotCoord3Dpoints (or straightforwardly use the primitivepoints3d()).range()computes axis-aligned ranges
-
-
Point1D,Line2D, andPlane3DR6 classesas_point1d()casts objects toPoint1DR6 classesas_line2d()casts objects toLine2DR6 classesas_plane3d()casts objects toPlane3DR6 classesis_point1d()tests whether objects arePoint1DR6 classesis_line2d()tests whether objects areLine2DR6 classesis_plane3d()tests whether objects arePlane3DR6 classes
-
transform1d(),transform2d(), andtransform3d()create 1D/2D/3D affine transformation matrix S3 classesis_transform1d(),is_transform2d(), andis_transform3d()test iftransform1d(),transform2d(), ortransform3d()objects.as_transform1d(),as_transform2d(), andas_transform3d()cast objects totransform1d(),transform2d(), ortransform3d()objects.permute2d()andpermute3d()transformation matrices permutes coordinate axes.project1d(),project2d(), andproject3d()create projection matrices.reflect1d(),reflect2d()andreflect3d()create reflection affine transformation matrices.rotate2d()androtate3d()create rotation affine transformation matrices.
rotate3d_to_AA()converts from 3D rotation matrix to axis-angle representation.scale1d(),scale2d(), andscale3d()create scaling affine transformation matrices.shear2d()andshear3d()create shearing affine transformation matrices.translate1d(),translate2d(), andtranslate3d()create translation affine transformation matrices.
-
{affiner}supports the following options settable bybase::options():affiner_angular_unit: The default for theunitargument used byangle()andas_angle().
The default for this option is "degrees".affiner_grid_unit: The default for theunitargument used byaffine_settings().
The default for this option isinches.- These options can be queried with the convenience function
affiner_options().