Skip to contents

Generates random three-velocities or four-velocities, optionally specifiying a magnitude

Usage

r3vel(n=7, r = NA)
r4vel(...)
rboost(r = NA)

Arguments

n

Number of three- or four- velocities to generate

r

Absolute value of the three-velocities, with default NA meaning to sample uniformly from the unit ball

...

Arguments passed to r3vel()

Details

Function r3vel() returns a random three-velocity. Function r4vel() is a convenience wrapper for as.4vel(r3vel()).

Function rboost() returns a random \(4\times 4\) Lorentz boost matrix, drawn from the connected component. If given r=0, then a transform corresponding to a random rotation will be returned.

Value

Returns a vector of three- or four- velocities.

Author

Robin K. S. Hankin

Note

If the speed of light is infinite, these functions require a specified argument for r.

It is not entirely trivial to sample uniformly from the unit ball or unit sphere, but it is not hard either.

Examples


r3vel()
#> A vector of three-velocities (speed of light = 1)
#>                x           y           z
#> [1,] -0.45646828 -0.14605170  0.58970407
#> [2,]  0.24172040  0.52732322  0.40075655
#> [3,] -0.13891530  0.52066535 -0.56540025
#> [4,]  0.88848514  0.03080818 -0.43238351
#> [5,] -0.27141412  0.54346958  0.27619711
#> [6,] -0.01135609 -0.65786259 -0.07659117
#> [7,] -0.35032850  0.81683309  0.33793502

a <- r3vel(10000)
b <- r3vel(1000,0.8)
u <- as.3vel(c(0,0,0.9))

pairs(unclass(u+a),asp=1)

pairs(unclass(a+u),asp=1)


is.consistent.boost(rboost())
#> [1] TRUE

sol(299792458)    # switch to SI units
#> [1] 299792458
sound <- 343      # speed of sound in metres per second
r3vel(100,343)    # random 3-velocities with speed = 343 m/s
#> A vector of three-velocities (speed of light = 299792458)
#>                   x           y            z
#>   [1,]  223.3637271 -254.074729  -56.6010367
#>   [2,]  295.9875562  153.450280   80.5815004
#>   [3,]  174.7920729  102.514653  276.7444259
#>   [4,]  324.9495888  105.319219  -31.0584433
#>   [5,]   -0.1038609  244.593553  240.4640989
#>   [6,]  226.7075156  253.355045  -45.4304266
#>   [7,] -186.3741656  245.827043  149.9424395
#>   [8,]  140.5583043  237.562485 -203.6085184
#>   [9,]  340.9010218   26.507370   27.0712519
#>  [10,]   55.8010975  -31.394440  336.9712550
#>  [11,]   71.8624435 -308.323889  131.9892738
#>  [12,]   63.0429839 -200.927521 -270.7447386
#>  [13,]  296.5805652  171.836706  -12.6930956
#>  [14,] -222.7324858  119.783992  231.7132605
#>  [15,]   54.5412062  330.091707   75.5891625
#>  [16,] -154.7347782   71.075970 -297.7488118
#>  [17,]  256.5838815   62.027114  219.0122118
#>  [18,]   72.4701149  241.222192 -232.8281262
#>  [19,] -129.5365142 -281.960402 -146.1766850
#>  [20,]  198.3639932  -56.170712 -274.1269365
#>  [21,] -124.9898118   55.209131  314.6084850
#>  [22,] -178.4840530   94.440229 -277.2606823
#>  [23,]  111.3058995  198.478312  256.6444165
#>  [24,] -166.1107486 -188.965840  233.1268549
#>  [25,]  159.1668167   60.985050 -297.6503790
#>  [26,]   19.7868900  250.899966  233.0379502
#>  [27,]  161.9906476  281.049044 -111.4426543
#>  [28,] -101.2627047  134.476626 -298.8492961
#>  [29,]   38.3897542   67.689065 -334.0560091
#>  [30,]  -52.9485477 -192.224848 -279.0968630
#>  [31,]   41.4137920  334.082646   65.7471174
#>  [32,] -150.4809062  105.952929 -289.4451135
#>  [33,]  128.3907123    4.057077 -318.0383076
#>  [34,] -259.4231391 -189.206130  120.6220345
#>  [35,] -323.1727689 -104.581318  -47.6561579
#>  [36,] -270.4329806 -188.002157   95.7611204
#>  [37,] -200.2002195  -60.379922 -271.8880967
#>  [38,] -269.5107055 -206.496273  -48.7059446
#>  [39,] -200.9015116  145.189925 -237.0811428
#>  [40,] -222.9571964 -118.826718 -231.9898695
#>  [41,]  271.0710787 -166.645334 -128.0578107
#>  [42,] -326.7156279  -32.804370  -99.1452054
#>  [43,]    0.6571765   88.038690 -331.5083063
#>  [44,]  167.1621621  150.170658 -259.1420169
#>  [45,] -120.8995477  -83.630189  309.9004530
#>  [46,]  187.7939173 -282.198817  -52.4048878
#>  [47,] -109.1324069  -91.350793  312.0803588
#>  [48,] -283.9026443  192.026051   13.2016720
#>  [49,]  131.6985705 -157.153262 -274.9678867
#>  [50,]  120.2380853  319.790239  -30.4303420
#>  [51,]  231.4134483  253.171996    0.8697855
#>  [52,]  -53.8973644 -239.581740 -239.4674593
#>  [53,]   14.4945628   31.201831  341.2702058
#>  [54,]  289.2158328  180.910046  -35.7037461
#>  [55,]  -82.9041710 -225.386346 -244.9018039
#>  [56,]   68.8252150  177.694782 -285.1958173
#>  [57,]  245.9550061 -237.970629   22.9153779
#>  [58,]   10.9365679 -184.285427 -289.0817753
#>  [59,]  -61.1548670 -222.938879 -253.3916704
#>  [60,]  224.1149912 -219.491841  138.7256371
#>  [61,] -245.6392277 -149.027637  187.3529647
#>  [62,] -278.1466626  198.858752  -27.1777667
#>  [63,] -316.3065087  -63.138369  116.6736427
#>  [64,] -293.6583269  157.517795   81.2522694
#>  [65,]  190.3211425 -107.283145 -264.4185877
#>  [66,]   -2.2221735  271.560622  209.5206212
#>  [67,]  146.0051262 -181.017715 -252.1191983
#>  [68,] -103.1493296  284.047501  162.2536070
#>  [69,]  250.0363911 -192.341521  134.6682674
#>  [70,]   50.4533834  339.180380    7.7540916
#>  [71,]   95.5431531   46.518756 -326.1234601
#>  [72,]   62.4903065 -234.062273  242.8143611
#>  [73,] -315.7474918   10.784228 -133.5523188
#>  [74,]  209.6173551 -216.127125 -164.3125987
#>  [75,]   85.2519089   90.578311 -319.6508745
#>  [76,]    2.4643883 -238.454130 -246.5411823
#>  [77,] -147.7155147 -278.074961 -136.0273597
#>  [78,]  279.1687341  183.367200   78.0402975
#>  [79,]  276.1017311  176.974072  100.4838886
#>  [80,]   39.5506973  318.735366 -120.3848353
#>  [81,] -217.5315978 -181.690723 -193.1773410
#>  [82,] -189.5233145 -251.636508  135.6797011
#>  [83,]  227.3832621  -71.231441 -246.7223824
#>  [84,] -247.7408332  -15.813754  236.6926377
#>  [85,]  281.5670855  192.132821   38.1307658
#>  [86,] -294.9147680   64.072197  163.0001017
#>  [87,]  306.6753502   85.924681  127.3427610
#>  [88,]  206.2407041 -243.971577  124.8664943
#>  [89,]  269.9749933  125.112785  170.6144604
#>  [90,] -144.0253575   99.421114  294.9934551
#>  [91,]   49.3198382  135.889372  311.0476363
#>  [92,]  209.5728550  270.403356   24.7031070
#>  [93,]  154.4194922 -224.922568 -207.8784718
#>  [94,]  219.5527314  165.794695 -204.8358302
#>  [95,] -127.8892224 -184.104180 -259.6131693
#>  [96,]  112.7666997  309.326201  -96.1767779
#>  [97,]   55.2166206   90.036071  326.3336189
#>  [98,]  205.3759527  196.140746  192.3500082
#>  [99,] -171.5250023   29.095191 -295.6038624
#> [100,]   42.8275552   32.163329  338.7924450

sol(1)   # return to default c=1
#> [1] 1