affiner 0.1.3
CRAN release: 2024-12-02
-
isocubeGrob()andgrid.isocube()now make sure that thefillofgp_borderis always"transparent"(#58).
affiner 0.1.1
CRAN release: 2024-10-14
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.
-
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 aroundas_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 classesis_coord1d(),is_coord2d(), andis_coord3d()test whether objects areCoord1D,Coord2D, orCoord3DR6 classesas_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 norm -
convex_hull2d()computes convex hull (currently just forCoord2Dvectors) -
cross_product3d()computes a cross product betweenCoord3Dvectors -
distance1d(),distance2d(), anddistance3d()computes Euclidean distances -
mean()computes centroids of coordinates -
normal2d()computesCoord2Dnormals -
normal3d()computesCoord3Dnormals -
plot()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 classes-
as_point1d()casts objects toPoint1DR6 classes -
as_line2d()casts objects toLine2DR6 classes -
as_plane3d()casts objects toPlane3DR6 classes -
is_point1d()tests whether objects arePoint1DR6 classes -
is_line2d()tests whether objects areLine2DR6 classes -
is_plane3d()tests whether objects arePlane3DR6 classes
-
-
transform1d(),transform2d(), andtransform3d()create 1D/2D/3D affine transformation matrix S3 classes-
is_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 by
base::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().
-
