JavaCAD
YModifier.java
Go to the documentation of this file.
1 /*
2  * To change this license header, choose License Headers in Project Properties.
3  * To change this template file, choose Tools | Templates
4  * and open the template in the editor.
5  */
6 package eu.mihosoft.vrl.v3d;
7 
8 // TODO: Auto-generated Javadoc
14 public class YModifier implements WeightFunction {
15 
17  private Bounds bounds;
18 
20  private double min = 0;
21 
23  private double max = 1.0;
24 
26  private double sPerUnit;
27 
29  private boolean centered;
30 
34  public YModifier() {
35  }
36 
42  public YModifier(boolean centered) {
43  this.centered = centered;
44  }
45 
46  /* (non-Javadoc)
47  * @see eu.mihosoft.vrl.v3d.WeightFunction#eval(eu.mihosoft.vrl.v3d.Vector3d, eu.mihosoft.vrl.v3d.CSG)
48  */
49  @Override
50  public double eval(Vector3d pos, CSG csg) {
51 
52  if (bounds == null) {
53  this.bounds = csg.getBounds();
54  sPerUnit = (max - min) / (bounds.getMax().y - bounds.getMin().y);
55  }
56 
57  double s = sPerUnit * (pos.y - bounds.getMin().y);
58 
59  if (centered) {
60  s = s - (max - min) / 2.0;
61 
62  s = Math.abs(s) * 2;
63  }
64 
65  return s;
66  }
67 
68 }
static Vector3d y(double y)
Definition: Vector3d.java:484
double eval(Vector3d pos, CSG csg)
Definition: YModifier.java:50
YModifier(boolean centered)
Definition: YModifier.java:42