This class is an extension (but not a subclass of) point(). It simply attaches a numeric weight to the point that is carried along with it. However, most of the functionality of points are lost with this vector class as all the a math and sorting operations are gone due to ambiguity on whether to operate on the point or the weight. Weighted points can easily be converted to points however.

weighted_point(..., default_dim = 2)

is_weighted_point(x)

as_weighted_point(x)

## Arguments

...

Various input. See the Constructor section.

default_dim

The dimensionality when constructing an empty vector

x

A point vector or an object to convert to it

## Value

a euclid_point_w vector

## Constructors

2 dimensional weighted points

• Providing three numeric vector will construct points with those x and y coordinate and a weight.

• Providing a point and a numeric will construct points with the given weight

3 dimensional weighted points

• Providing four numeric vector will construct points with those x, y and z coordinate and a weight.

• Providing a point and a numeric will construct points with the given weight

Other Geometries: circle(), direction(), iso_cube(), iso_rect(), line(), plane(), point(), ray(), segment(), sphere(), tetrahedron(), triangle(), vec()

Other Locations: barycenter(), bisector(), centroid(), circumcenter(), equidistant_line(), point(), radical()

## Examples

# Construction
wp <- weighted_point(sample(5), sample(5), runif(5))
wp
#> <2D point_ws >
#>  <x:3, y:3, w:0.5>   <x:2, y:1, w:0.169> <x:1, y:4, w:0.406>
#>  <x:4, y:5, w:0.123> <x:5, y:2, w:0.834>

# Convert to point
p <- as_point(wp)
p
#> <2D points >
#>  <x:3, y:3> <x:2, y:1> <x:1, y:4> <x:4, y:5> <x:5, y:2>

# Construct from point and weight

weighted_point(p, 1:5)
#> <2D point_ws >
#>  <x:3, y:3, w:1> <x:2, y:1, w:2> <x:1, y:4, w:3> <x:4, y:5, w:4>
#>  <x:5, y:2, w:5>