use of com.ardor3d.math.Vector3 in project energy3d by concord-consortium.
the class Foundation method setHeight.
@Override
public void setHeight(final double height) {
final double delta = height - this.height;
if (!Util.isZero(delta)) {
this.height = height;
for (final HousePart c : children) {
final int n = c.points.size();
for (int i = 0; i < n; i++) {
final Vector3 v = c.points.get(i);
v.setZ(v.getZ() + delta);
}
}
}
}
use of com.ardor3d.math.Vector3 in project energy3d by concord-consortium.
the class Foundation method getSolarReceiverCenter.
public Vector3 getSolarReceiverCenter() {
double rx = 0;
double ry = 0;
int count = 0;
for (final HousePart p : children) {
if (p instanceof Wall) {
final Vector3 c = p.getAbsCenter();
rx += c.getX();
ry += c.getY();
count++;
}
}
Vector3 o;
if (count == 0) {
o = getAbsCenter();
o.setZ(getSolarReceiverHeight(0.1));
} else {
o = new Vector3(rx / count, ry / count, getSolarReceiverHeight(0.1));
}
return o;
}
use of com.ardor3d.math.Vector3 in project energy3d by concord-consortium.
the class Foundation method updateHandle.
private void updateHandle(final Vector3 p, final ReadOnlyVector3 dir) {
final ReadOnlyVector3 step = dir.normalize(null).multiplyLocal(3);
if (step.length() == 0) {
return;
}
final ReadOnlyVector3 center = getCenter();
p.set(center).addLocal(dir).addLocal(step);
final Point2D p2D = new Point2D.Double();
for (final HousePart part : Scene.getInstance().getParts()) {
if (part != this && part instanceof Foundation) {
final ArrayList<Vector3> points = part.getPoints();
final Path2D foundationPoly = new Path2D.Double();
foundationPoly.moveTo(points.get(0).getX(), points.get(0).getY());
foundationPoly.lineTo(points.get(2).getX(), points.get(2).getY());
foundationPoly.lineTo(points.get(3).getX(), points.get(3).getY());
foundationPoly.lineTo(points.get(1).getX(), points.get(1).getY());
foundationPoly.closePath();
p2D.setLocation(p.getX(), p.getY());
if (foundationPoly.contains(p2D)) {
while (foundationPoly.contains(p2D)) {
p.addLocal(step);
p2D.setLocation(p.getX(), p.getY());
}
p.addLocal(step);
}
}
}
}
use of com.ardor3d.math.Vector3 in project energy3d by concord-consortium.
the class Foundation method drawAzimuthArrow.
public void drawAzimuthArrow() {
final double cos30 = Math.cos(Math.toRadians(30));
final double sin30 = Math.sin(Math.toRadians(30));
final FloatBuffer arrowVertices = azimuthArrow.getMeshData().getVertexBuffer();
arrowVertices.clear();
final Vector3 v = getAbsPoint(0).subtractLocal(getAbsPoint(1)).normalizeLocal().multiplyLocal(20).negateLocal();
final Vector3 p = getAbsPoint(1).addLocal(getAbsPoint(3)).multiplyLocal(0.5);
arrowVertices.put(p.getXf()).put(p.getYf()).put(p.getZf());
p.addLocal(v);
arrowVertices.put(p.getXf()).put(p.getYf()).put(p.getZf());
final double arrowX = v.getX() / v.length();
final double arrowY = v.getY() / v.length();
final float r = 3;
float wingx = (float) (r * (arrowX * cos30 + arrowY * sin30));
float wingy = (float) (r * (arrowY * cos30 - arrowX * sin30));
arrowVertices.put(p.getXf()).put(p.getYf()).put(p.getZf());
arrowVertices.put(p.getXf() - wingx).put(p.getYf() - wingy).put(p.getZf());
wingx = (float) (r * (arrowX * cos30 - arrowY * sin30));
wingy = (float) (r * (arrowY * cos30 + arrowX * sin30));
arrowVertices.put(p.getXf()).put(p.getYf()).put(p.getZf());
arrowVertices.put(p.getXf() - wingx).put(p.getYf() - wingy).put(p.getZf());
azimuthArrow.getMeshData().updateVertexCount();
azimuthArrow.updateModelBound();
updateAzimuthArrowVisibility(SceneManager.getInstance().getSelectedPart() == this);
}
use of com.ardor3d.math.Vector3 in project energy3d by concord-consortium.
the class Foundation method getAzimuth.
/**
* @return the azimuth of the reference vector of this foundation in degrees
*/
public double getAzimuth() {
final Vector3 v = getAbsPoint(0);
final Vector3 v1 = getAbsPoint(1);
final double ly = v.distance(v1);
double a = 90 + Math.toDegrees(Math.asin((v.getY() - v1.getY()) / ly));
if (v.getX() > v1.getX()) {
a = 360 - a;
}
if (Util.isZero(a - 360)) {
a = 0;
}
return a;
}
Aggregations