public float len () { return a.dst(b); }
public float len () { return a.dst(b); }
public AmbientCubemap add (final Color color, final Vector3 point, final Vector3 target, final float intensity) { final float t = intensity / (1f + target.dst(point)); return add(color.r * t, color.g * t, color.b * t, target.x - point.x, target.y - point.y, target.z - point.z); }
public AmbientCubemap add (final Color color, final Vector3 point, final Vector3 target, final float intensity) { final float t = intensity / (1f + target.dst(point)); return add(color.r * t, color.g * t, color.b * t, target.x - point.x, target.y - point.y, target.z - point.z); }
/** Compute final result. * @param bb BoundingBox encompassing instances * @param camera Camera to compute */ protected void computeResult (BoundingBox bb, Camera camera) { // Radius float radius = bb1.getDimensions(tmpV).len() * 0.5f; // Center bb1.getCenter(tmpV); // Computation float distance = tmpV.dst(camera.position); float near = distance - radius; float far = distance + radius; if (near <= 0) near = CAMERA_NEAR; if (far <= 0) far = CAMERA_FAR; camera.near = near; camera.far = far; camera.update(); } }
/** Checks whether the line segment and the circle intersect and returns by how much and in what direction the line has to move * away from the circle to not intersect. * * @param start The line segment starting point * @param end The line segment end point * @param point The center of the circle * @param radius The radius of the circle * @param displacement The displacement vector set by the method having unit length * @return The displacement or Float.POSITIVE_INFINITY if no intersection is present */ public static float intersectSegmentCircleDisplace (Vector2 start, Vector2 end, Vector2 point, float radius, Vector2 displacement) { float u = (point.x - start.x) * (end.x - start.x) + (point.y - start.y) * (end.y - start.y); float d = start.dst(end); u /= d * d; if (u < 0 || u > 1) return Float.POSITIVE_INFINITY; tmp.set(end.x, end.y, 0).sub(start.x, start.y, 0); tmp2.set(start.x, start.y, 0).add(tmp.scl(u)); d = tmp2.dst(point.x, point.y, 0); if (d < radius) { displacement.set(point).sub(tmp2.x, tmp2.y).nor(); return d; } else return Float.POSITIVE_INFINITY; }
/** Checks whether the line segment and the circle intersect and returns by how much and in what direction the line has to move * away from the circle to not intersect. * * @param start The line segment starting point * @param end The line segment end point * @param point The center of the circle * @param radius The radius of the circle * @param displacement The displacement vector set by the method having unit length * @return The displacement or Float.POSITIVE_INFINITY if no intersection is present */ public static float intersectSegmentCircleDisplace (Vector2 start, Vector2 end, Vector2 point, float radius, Vector2 displacement) { float u = (point.x - start.x) * (end.x - start.x) + (point.y - start.y) * (end.y - start.y); float d = start.dst(end); u /= d * d; if (u < 0 || u > 1) return Float.POSITIVE_INFINITY; tmp.set(end.x, end.y, 0).sub(start.x, start.y, 0); tmp2.set(start.x, start.y, 0).add(tmp.scl(u)); d = tmp2.dst(point.x, point.y, 0); if (d < radius) { displacement.set(point).sub(tmp2.x, tmp2.y).nor(); return d; } else return Float.POSITIVE_INFINITY; }
int divisions) { Vector3 begin = obtainV3().set(x1, y1, z1), end = obtainV3().set(x2, y2, z2); float length = begin.dst(end); float coneHeight = length * capLength; float coneDiameter = 2 * (float)(coneHeight * Math.sqrt(1f / 3));
int divisions) { Vector3 begin = obtainV3().set(x1, y1, z1), end = obtainV3().set(x2, y2, z2); float length = begin.dst(end); float coneHeight = length * capLength; float coneDiameter = 2 * (float)(coneHeight * Math.sqrt(1f / 3));
/** * see {@link Vector3#dst} */ public float getDistanceTo(Position other) { return other.xyz.dst(xyz); }
public float len () { return a.dst(b); }
protected boolean checkClickDistance(int screenX, int screenY, Vector3 pos, NaturalCamera camera, PerspectiveCamera pcamera, double pixelSize) { return pos.dst(screenX % pcamera.viewportWidth, screenY, pos.z) <= pixelSize; }
public AmbientCubemap add (final Color color, final Vector3 point, final Vector3 target, final float intensity) { final float t = intensity / (1f + target.dst(point)); return add(color.r * t, color.g * t, color.b * t, target.x - point.x, target.y - point.y, target.z - point.z); }
Circle3 circumcircle() { float u = ((a.x-b.x)*(a.x+b.x) + (a.y-b.y)*(a.y+b.y)) / 2.0f; float v = ((b.x-c.x)*(b.x+c.x) + (b.y-c.y)*(b.y+c.y)) / 2.0f; float den = (a.x-b.x)*(b.y-c.y) - (b.x-c.x)*(a.y-b.y); if ( den==0 ) // oops, degenerate case circum = new Circle3( a, Float.POSITIVE_INFINITY ); else { Vector3 cen = new Vector3((u*(b.y-c.y) - v*(a.y-b.y)) / den, (v*(a.x-b.x) - u*(b.x-c.x)) / den, 0); circum = new Circle3( cen, cen.dst(a) ); } return circum; }
@Override protected void scaleHandles() { ProjectContext projectContext = getProjectManager().current(); Vector3 pos = projectContext.currScene.currentSelection.getPosition(temp0); float scaleFactor = projectContext.currScene.cam.position.dst(pos) * 0.005f; xHandle.getScale().set(scaleFactor, scaleFactor, scaleFactor); xHandle.applyTransform(); yHandle.getScale().set(scaleFactor, scaleFactor, scaleFactor); yHandle.applyTransform(); zHandle.getScale().set(scaleFactor, scaleFactor, scaleFactor); zHandle.applyTransform(); }
@Override protected void scaleHandles() { Vector3 pos = getProjectManager().current().currScene.currentSelection.getPosition(temp0); float scaleFactor = getProjectManager().current().currScene.cam.position.dst(pos) * 0.25f; xHandle.getScale().set(scaleFactor * 0.7f, scaleFactor / 2, scaleFactor / 2); xHandle.applyTransform(); yHandle.getScale().set(scaleFactor / 2, scaleFactor * 0.7f, scaleFactor / 2); yHandle.applyTransform(); zHandle.getScale().set(scaleFactor / 2, scaleFactor / 2, scaleFactor * 0.7f); zHandle.applyTransform(); xzPlaneHandle.getScale().set(scaleFactor * 0.13f, scaleFactor * 0.13f, scaleFactor * 0.13f); xzPlaneHandle.applyTransform(); }
@Override protected void scaleHandles() { Vector3 pos = getProjectManager().current().currScene.currentSelection.getPosition(temp0); float scaleFactor = getProjectManager().current().currScene.cam.position.dst(pos) * 0.01f; xHandle.getScale().set(scaleFactor, scaleFactor, scaleFactor); xHandle.applyTransform(); yHandle.getScale().set(scaleFactor, scaleFactor, scaleFactor); yHandle.applyTransform(); zHandle.getScale().set(scaleFactor, scaleFactor, scaleFactor); zHandle.applyTransform(); xyzHandle.getScale().set(scaleFactor, scaleFactor, scaleFactor); xyzHandle.applyTransform(); }