The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
In {affiner}
angles are represented by the angle()
class:
Supports the following angular units (note we ignore any punctuation and space characters as well as any trailing s’s e.g. “half turns” will be treated as equivalent to “halfturn”):
degrees()
, gradians()
, pi_radians()
, radians()
, turns()
are convenience wrappers around as_angle.()
that specifies the angular unit.
One can use the affiner_angular_unit
global option to set the default angular unit used by this package from “degrees” to “gradians”, (multiples of) “pi-radians”, “radians”, or “turns”.
Use is_congruent()
to check if two angles are congruent modulo full turns.
library("affiner")
as_angle(90, "degrees") + turns(1)
## <angle<degrees>[1]>
## [1] 450°
is_congruent(degrees(180), radians(pi))
## [1] TRUE
as.numeric(turns(1/3), "radians")
## [1] 2.094395
{affiner}
provides several angle()
class aware trigonometric functions:
sine()
, cosine()
, tangent()
, secant()
, cosecant()
, cotangent()
,arcsine()
, arccosine()
, arctangent()
, arcsecant()
, arccosecant()
, and arccotangent()
. arcsine()
and arccosine()
also feature a tolerance
value so that values that exceed the 1
/ -1
cutoffs by a small tolerance are rounded to those values.sin()
, cos()
, and tan()
on angle()
objects.library("affiner")
sin(2 * pi)
## [1] -2.449294e-16
sine(degrees(360))
## [1] 0
arctangent(x = 0, y = 1)
## <angle<degrees>[1]>
## [1] 90°
In {affiner}
2D Coordinates are represented by a Coord2D
R6 class:
Create Coord2D
objects with as_coord2d()
Coord2D
R6 objects supports several affine transformation methods that can be chained:
permute()
project()
reflect()
rotate()
scale()
shear()
translate()
transform()
{affiner}
affine transformations are post-multiplied so affine transformations can be applied in an intuitive order.abs()
computes Euclidean norm and distance2d()
computes Euclidean distancesconvex_hull2d()
computes the convex hull.range()
computes the axis-aligned bounding box ranges.# Cartesian coordinates
library("affiner")
as_coord2d(x = 1:10, y = 1:10)
p <-print(p)
## <Coord2D[10]>
## x y w
## [1,] 1 1 1
## [2,] 2 2 1
## [3,] 3 3 1
## [4,] 4 4 1
## [5,] 5 5 1
## [6,] 6 6 1
## [7,] 7 7 1
## [8,] 8 8 1
## [9,] 9 9 1
## [10,] 10 10 1
p$
p2 <- clone()$
scale(x = 0.5)$
rotate(degrees(90))$
reflect(as_line2d("y-axis"))$
translate(as_coord2d(x = 0.5, y = 0.5))$
print()
## <Coord2D[10]>
## x y w
## [1,] 1.0 1.0 1
## [2,] 1.5 1.5 1
## [3,] 2.0 2.0 1
## [4,] 2.5 2.5 1
## [5,] 3.0 3.0 1
## [6,] 3.5 3.5 1
## [7,] 4.0 4.0 1
## [8,] 4.5 4.5 1
## [9,] 5.0 5.0 1
## [10,] 5.5 5.5 1
# Polar coordinates
degrees(seq(0, 300, by = 60))
theta <- 1
radius <- as_coord2d(theta, radius = radius)
p <-is_congruent(as_angle(p), theta) |> all()
## [1] TRUE
is_congruent(abs(p), radius) |> all()
## [1] TRUE
In {affiner}
3D Coordinates are represented by a Coord3D
R6 class:
Create Coord3D
objects with as_coord3d()
Coord3D
R6 objects supports several affine transformation methods that can be chained:
permute()
project()
reflect()
rotate()
scale()
shear()
translate()
transform()
{affiner}
affine transformations are post-multiplied so affine transformations can be applied in an intuitive order.abs()
computes Euclidean norm and distance3d()
computes Euclidean distancesrange()
computes the axis-aligned bounding box ranges.cross_product3d()
computes cross products (*
computes inner products).# Cartesian coordinates
library("affiner")
as_coord3d(x = 1:10, y = 1:10, z = 1:10)
p <-print(p)
## <Coord3D[10]>
## x y z w
## [1,] 1 1 1 1
## [2,] 2 2 2 1
## [3,] 3 3 3 1
## [4,] 4 4 4 1
## [5,] 5 5 5 1
## [6,] 6 6 6 1
## [7,] 7 7 7 1
## [8,] 8 8 8 1
## [9,] 9 9 9 1
## [10,] 10 10 10 1
p$
p2 <- clone()$
scale(z = 0.5)$
rotate(axis = as_coord3d("z-axis"), theta = degrees(90))$
reflect(as_plane3d("yz-plane"))$
shear(xy_shear = 0.5)$
translate(as_coord3d(x = 0.5, y = 0.5, z = 0.5))$
print()
## <Coord3D[10]>
## x y z w
## [1,] 2.0 1.5 1.0 1
## [2,] 3.5 2.5 1.5 1
## [3,] 5.0 3.5 2.0 1
## [4,] 6.5 4.5 2.5 1
## [5,] 8.0 5.5 3.0 1
## [6,] 9.5 6.5 3.5 1
## [7,] 11.0 7.5 4.0 1
## [8,] 12.5 8.5 4.5 1
## [9,] 14.0 9.5 5.0 1
## [10,] 15.5 10.5 5.5 1
# Spherical coordinates
as_angle(p, type = "inclination")
inclination <- as_angle(p, type = "azimuth")
azimuth <- abs(p)
radius <- as_coord3d(azimuth, radius = radius, inclination = inclination)
ps <-all.equal(p, ps)
## [1] TRUE
# Cylindrical coordinates
as_coord2d(p, plane = "xy-plane") |> abs()
radius <- as_coord3d(azimuth, radius = radius, z = p$z)
pc <-all.equal(p, pc)
## [1] TRUE
{affiner}
can project Coord3D
objects to Coord2D
objects using orthographic/axonometric and oblique projections:
For a multiview/primary orthographic projection onto the xy-plane use as_coord2d(x)
For a multiview/primary orthographic projection onto the xz-plane use as_coord2d(x, permutation = "xzy")
For a “cabinet” oblique projection onto the xy-plane use as_coord2d(x, scale = 0.5)
For a “cabinet” oblique projection onto the xz-plane use as_coord2d(x, permutation = "xzy", scale = 0.5)
For other oblique projections manipulate the scale
parameter (usually from 0.5 to 1.0) and the alpha
angle parameter (usually from 30° to 45°).
For one “isometric” axonometric projection one can use
x$
clone()$
translate(-mean(x)$
rotate("z-axis", degrees(45))$
rotate("x-axis", degrees(-90 + 35.264)) |>
as_coord2d()
Other axonometric projections can be achieved with the right 3D rotations
See vignette("affiner", package = "affiner")
for some visual examples
Recall one can use “scale” affine transformation to flip signs of x/y/z axes and “permute” affine transformation to switch order of x/y/z coordinates
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.