Synthia
Generic and flexible data structure generator
Variation2.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 
24 import examples.util.Utilities;
25 
26 /**
27  * Generates two-dimensional points lying at right angles along a randomly
28  * selected circle. The points are generated by composing pickers as in the
29  * following diagram:
30  * <p>
31  * <img src="./doc-files/hypersphere/Variation2.png" alt="Diagram">
32  * <p>
33  * This variation shows the use of the {@link Freeze} picker: a random float
34  * value between 1 and 3 is picked for the radius, and this radius will then be
35  * used for all points produced by the {@link HyperspherePicker}. The angle is
36  * randomly selected among four values lying at intervals of &pi;/2. As a
37  * result, different seeds will produce sets of points lying at a different
38  * distance from the origin, but the same distance for each picker instance.
39  *
40  * @ingroup Examples
41  */
42 public class Variation2
43 {
44 
45  @SuppressWarnings("unchecked")
46  public static void main(String[] args)
47  {
48  GaussianFloat radius = new GaussianFloat();
49  Constant<Float> angle = new Constant<Float>((float) (3 * Math.PI / 4));
50  HyperspherePicker hp = new HyperspherePicker(radius, angle);
51  for (int i = 0; i < 100; i++)
52  {
53  Utilities.print(System.out, hp.pick());
54  }
55  }
56 
57 }
ca.uqac.lif.synthia.util
Miscellaneous pickers performing various functions.
Definition: ArrayPicker.java:19
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.util.Constant
Picker that returns the same object every time.
Definition: Constant.java:37
ca.uqac.lif.synthia.vector.HyperspherePicker
Generates n-dimensional vectors with a given modulus.
Definition: HyperspherePicker.java:42
ca.uqac.lif.synthia.random.GaussianFloat
Produces a float picked from a Gaussian probability distribution.
Definition: GaussianFloat.java:28
examples.hypersphere.Variation2
Generates two-dimensional points lying at right angles along a randomly selected circle.
Definition: Variation2.java:42
examples.util.Utilities
Object providing a few utility methods to simplify the examples in this project.
Definition: Utilities.java:30
ca.uqac.lif
ca
examples
examples.util.Utilities.print
static void print(PrintStream ps, Object o)
Prints an object to a print stream.
Definition: Utilities.java:37
examples.hypersphere.Variation2.main
static void main(String[] args)
Definition: Variation2.java:46