affiner 0.3.1
CRAN release: 2026-05-10
New features
as_ellipse2d()creates anEllipse2DR6 object representing a 2D ellipse (or vector of ellipses) (#46).-
as_polygon2d()creates aPolygon2DR6 object representing a 2D polygon (#46).-
isotoxal_2ngon_polygon2d()creates an isotoxal2n-gon [Polygon2D] object;star_polygon2d()is an alias (#78). -
rectangle_polygon2d()creates a rectangle [Polygon2D] object (#78). -
regular_ngon_polygon2d()creates a regular n-gon [Polygon2D] object (#78).
-
as_segment2d()creates aSegment2DR6 object representing a vector of 2D line segments (#75).dot_product1d(),dot_product2d(), anddot_product3d()are new exported functions that compute the dot (inner) product of two coordinate vectors (#61). You may also (continue to) use the*and (if R >= 4.3) the%*%operators to compute the dot (inner) product.has_overlap2d()tests whether two 2D objects (ellipses/circles or convex polygons) have a non-zero-area overlap (#46).as_coord2d.Coord3D()now supports oblique projections onto arbitrary planes (not just the xy-plane) and gains arollparameter to rotate the in-plane coordinate frame around the plane normal after the azimuth/inclination alignment.intersection()now supportsLine2DandEllipse2Dpairs, returning 0, 1, or 2 intersection points.is_ellipse2d()tests whether an object is aEllipse2DR6 class.is_segment2d()tests whether an object is aSegment2DR6 class.is_polygon2d()tests whether an object is aPolygon2DR6 class.painter_depth()computes painter’s algorithm depth values forCoord2D,Coord3D,Polygon2D, andSegment2Dobjects under parallel (orthographic or oblique) projections.painter_order()wrapspainter_depth()andorder()to return the integer indices for painter’s algorithm draw order (farthest first) forCoord2D,Coord3D,Segment2D, andPolygon2Dobjects.sort.Coord2D()andsort.Coord3D()sort coordinate/segment vectors by painter’s depth (farthest first by default), for use with the painter’s algorithm.
Bug fixes and minor improvements
-
permute3d()now correctly returns atransform3dobject instead of atransform2dobject. -
rotate3d()now correctly returns atransform3dobject instead of a plain matrix. -
shear3d()now correctly returns atransform3dobject instead of atransform2dobject. -
rgl::plot3d()method added forPlane3Dobjects (wrapsrgl::planes3d()).
affiner 0.2.1
CRAN release: 2026-01-28
-
has_intersection()is a generic S3 method which tests whether two objects have an intersection. -
intersection()is a generic S3 method which computes the intersection of two objects. -
is_equivalent()is a generic S3 method which tests whether two objects are “equivalent”. Theis_equivalent()method for angle vectors tests whether two angles are congruent. Theis_equivalent()method forPoint1D,Line2D,Plane3Dclasses tests whether they are the same point/line/plane after standardization. -
is_parallel()is a generic S3 method which tests whether two objects are “parallel” (e.g.Line2DandPlane3Dobjects). -
isotoxal_2ngon_inner_radius()computes the inner radius of an isotoxal2n-gon polygon (#66).star_inner_radius()is an alias. - If R >= 4.4.0 can now also use
crossprod()(in addition tocross_product3d()) to compute the vector cross product of twoCoord3Dobjects. - Can now use
ceiling(),floor(),round(),signif(), andtrunc()onCoord1D,Coord2D, andCoord3Dobjects (#63).
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().
-
