Synthia
Generic and flexible data structure generator
Variation1.java
Go to the documentation of this file.
1
/*
2
Synthia, a data structure generator
3
Copyright (C) 2019-2021 Laboratoire d'informatique formelle
4
Université du Québec à Chicoutimi, Canada
5
6
This program is free software: you can redistribute it and/or modify
7
it under the terms of the GNU Lesser General Public License as published
8
by the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
10
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU Lesser General Public License for more details.
15
16
You should have received a copy of the GNU Lesser General Public License
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
package
examples.hypersphere;
20
21
import
ca
.
uqac
.
lif
.
synthia
.
random
.
AffineTransform
.
AffineTransformFloat
;
22
import
ca
.
uqac
.
lif
.
synthia
.
random
.
RandomFloat
;
23
import
ca
.
uqac
.
lif
.
synthia
.
random
.
RandomInteger
;
24
import
ca
.
uqac
.
lif
.
synthia
.
vector
.
HyperspherePicker
;
25
import
examples
.
util
.
Utilities
;
26
27
/**
28
* Generates two-dimensional points lying along two concentric circles.
29
* The points are generated by composing pickers as in the following diagram:
30
* <p>
31
* <img src="./doc-files/hypersphere/Variation1.png" alt="Diagram">
32
* <p>
33
* For each point, a radius of either 1 or 2 is selected. A random floating
34
* point <i>x</i> between 0 and 1 is also selected, to which the affine
35
* transform 2π<i>x</i>+0 is then applied. The end result is that each
36
* point lies at any angle between 0 and 2π on the circle of radius 1 or 2.
37
* The two plots at the bottom represent the possible values one could
38
* obtain by starting from a different random seed.
39
*
40
* @ingroup Examples
41
*/
42
public
class
Variation1
43
{
44
45
@SuppressWarnings(
"unchecked"
)
46
public static
void
main
(String[] args)
47
{
48
RandomInteger
radius =
new
RandomInteger
(1, 3);
49
RandomFloat
r_float =
new
RandomFloat
().
setSeed
(42);
50
AffineTransformFloat angle =
new
AffineTransformFloat(r_float, 2 * Math.PI, 0);
51
HyperspherePicker
hp =
new
HyperspherePicker
(radius, angle);
52
for
(
int
i = 0; i < 100; i++)
53
{
54
Utilities
.
print
(System.out, hp.
pick
());
55
}
56
}
57
58
}
ca.uqac.lif.synthia.random.AffineTransform.AffineTransformFloat
Affine transform producing floats.
Definition:
AffineTransform.java:132
examples.hypersphere.Variation1.main
static void main(String[] args)
Definition:
Variation1.java:46
ca.uqac.lif.synthia.vector.HyperspherePicker.pick
float[] pick()
Picks an object.
Definition:
HyperspherePicker.java:97
ca.uqac.lif.synthia.vector
Pickers generating multi-dimensional numerical vectors.
Definition:
HyperspherePicker.java:19
ca.uqac
examples.util
Definition:
package-info.java:1
ca.uqac.lif.synthia.random
Pickers that produce pseudo-random objects such as numbers.
Definition:
AffineTransform.java:19
ca.uqac.lif.synthia
Definition:
Bounded.java:19
ca.uqac.lif.synthia.vector.HyperspherePicker
Generates n-dimensional vectors with a given modulus.
Definition:
HyperspherePicker.java:42
ca.uqac.lif.synthia.random.AffineTransform
Applies an affine transform to a value produced by another picker.
Definition:
AffineTransform.java:38
examples.util.Utilities
Object providing a few utility methods to simplify the examples in this project.
Definition:
Utilities.java:30
ca.uqac.lif.synthia.random.RandomFloat.setSeed
RandomFloat setSeed(int seed)
Definition:
RandomFloat.java:85
ca.uqac.lif
ca.uqac.lif.synthia.random.RandomInteger
Picks an integer uniformly in an interval.
Definition:
RandomInteger.java:31
ca
examples.hypersphere.Variation1
Generates two-dimensional points lying along two concentric circles.
Definition:
Variation1.java:42
examples
ca.uqac.lif.synthia.random.RandomFloat
Picks a floating point number uniformly in an interval.
Definition:
RandomFloat.java:30
examples.util.Utilities.print
static void print(PrintStream ps, Object o)
Prints an object to a print stream.
Definition:
Utilities.java:37
Source
Examples
src
examples
hypersphere
Variation1.java
Generated by
1.8.17