CPD Results
The following document contains the results of PMD's CPD 7.3.0.
Duplications
| File | Line |
|---|---|
| org\hipparchus\geometry\euclidean\threed\FieldVector3D.java | 674 |
| org\hipparchus\geometry\euclidean\threed\FieldVector3D.java | 710 |
public static <T extends CalculusFieldElement<T>> T angle(final FieldVector3D<T> v1, final FieldVector3D<T> v2)
throws MathRuntimeException {
final T normProduct = v1.getNorm().multiply(v2.getNorm());
if (normProduct.getReal() == 0) {
throw new MathRuntimeException(LocalizedCoreFormats.ZERO_NORM);
}
final T dot = dotProduct(v1, v2);
final double threshold = normProduct.getReal() * 0.9999;
if ((dot.getReal() < -threshold) || (dot.getReal() > threshold)) {
// the vectors are almost aligned, compute using the sine
FieldVector3D<T> v3 = crossProduct(v1, v2);
if (dot.getReal() >= 0) {
return v3.getNorm().divide(normProduct).asin();
}
return v3.getNorm().divide(normProduct).asin().subtract(dot.getPi()).negate();
}
// the vectors are sufficiently separated to use the cosine
return dot.divide(normProduct).acos();
}
/** Compute the angular separation between two vectors.
* <p>This method computes the angular separation between two
* vectors using the dot product for well separated vectors and the
* cross product for almost aligned vectors. This allows to have a
* good accuracy in all cases, even for vectors very close to each
* other.</p>
* @param v1 first vector
* @param v2 second vector
* @param <T> the type of the field elements
* @return angular separation between v1 and v2
* @exception MathRuntimeException if either vector has a null norm
*/
public static <T extends CalculusFieldElement<T>> T angle(final FieldVector3D<T> v1, final Vector3D v2)
|
|
| File | Line |
|---|---|
| org\hipparchus\geometry\partitioning\AbstractRegion.java | 476 |
| org\hipparchus\geometry\partitioning\RegionFactory.java | 182 |
final BSPTree<S, P, H, I> transformedTree = recurseTransform(getTree(false), transform, map);
// set up the boundary attributes splitters
for (final Map.Entry<BSPTree<S, P, H, I>, BSPTree<S, P, H, I>> entry : map.entrySet()) {
if (entry.getKey().getCut() != null) {
@SuppressWarnings("unchecked")
BoundaryAttribute<S, P, H, I> original = (BoundaryAttribute<S, P, H, I>) entry.getKey().getAttribute();
if (original != null) {
@SuppressWarnings("unchecked")
BoundaryAttribute<S, P, H, I> transformed = (BoundaryAttribute<S, P, H, I>) entry.getValue().getAttribute();
for (final BSPTree<S, P, H, I> splitter : original.getSplitters()) {
transformed.getSplitters().add(map.get(splitter));
}
}
}
}
return buildNew(transformedTree);
|
|
| File | Line |
|---|---|
| org\hipparchus\geometry\euclidean\threed\PolyhedronsSet.java | 430 |
| org\hipparchus\geometry\euclidean\threed\PolyhedronsSet.java | 534 |
return new BRep(vertices, facets);
}
/** {@inheritDoc} */
@Override
public Order visitOrder(final BSPTree<Euclidean3D, Vector3D, Plane, SubPlane> node) {
return Order.MINUS_SUB_PLUS;
}
/** {@inheritDoc} */
@Override
public void visitInternalNode(final BSPTree<Euclidean3D, Vector3D, Plane, SubPlane> node) {
@SuppressWarnings("unchecked")
final BoundaryAttribute<Euclidean3D, Vector3D, Plane, SubPlane> attribute =
(BoundaryAttribute<Euclidean3D, Vector3D, Plane, SubPlane>) node.getAttribute();
if (attribute.getPlusOutside() != null) {
addContribution(attribute.getPlusOutside(), false);
}
if (attribute.getPlusInside() != null) {
addContribution(attribute.getPlusInside(), true);
}
}
/** {@inheritDoc} */
@Override
public void visitLeafNode(final BSPTree<Euclidean3D, Vector3D, Plane, SubPlane> node) {
}
/** Add the contribution of a boundary facet.
* @param facet boundary facet
* @param reversed if true, the facet has the inside on its plus side
* @exception MathRuntimeException if facet is unbounded
*/
private void addContribution(final SubPlane facet, final boolean reversed)
|
|
| File | Line |
|---|---|
| org\hipparchus\geometry\euclidean\threed\FieldVector3D.java | 264 |
| org\hipparchus\geometry\euclidean\threed\FieldVector3D.java | 308 |
this.x = prototype.linearCombination(a1, u1.getX(), a2, u2.getX(), a3, u3.getX(), a4, u4.getX());
this.y = prototype.linearCombination(a1, u1.getY(), a2, u2.getY(), a3, u3.getY(), a4, u4.getY());
this.z = prototype.linearCombination(a1, u1.getZ(), a2, u2.getZ(), a3, u3.getZ(), a4, u4.getZ());
}
/** Linear constructor.
* Build a vector from four other ones and corresponding scale factors.
* The vector built will be a1 * u1 + a2 * u2 + a3 * u3 + a4 * u4
* @param a1 first scale factor
* @param u1 first base (unscaled) vector
* @param a2 second scale factor
* @param u2 second base (unscaled) vector
* @param a3 third scale factor
* @param u3 third base (unscaled) vector
* @param a4 fourth scale factor
* @param u4 fourth base (unscaled) vector
*/
public FieldVector3D(final T a1, final Vector3D u1,
|
|
| File | Line |
|---|---|
| org\hipparchus\geometry\partitioning\RegionFactory.java | 297 |
| org\hipparchus\geometry\partitioning\RegionFactory.java | 349 |
IntersectionMerger(final Region<S, P, H, I> region1, final Region<S, P, H, I> region2) {
super(region1, region2);
}
/** {@inheritDoc} */
@Override
public BSPTree<S, P, H, I> merge(final BSPTree<S, P, H, I> leaf, final BSPTree<S, P, H, I> tree,
final BSPTree<S, P, H, I> parentTree,
final boolean isPlusChild, final boolean leafFromInstance) {
if ((Boolean) leaf.getAttribute()) {
|
|
| File | Line |
|---|---|
| org\hipparchus\geometry\euclidean\threed\FieldVector3D.java | 204 |
| org\hipparchus\geometry\euclidean\threed\FieldVector3D.java | 242 |
this.x = prototype.linearCombination(a1, u1.getX(), a2, u2.getX(), a3, u3.getX());
this.y = prototype.linearCombination(a1, u1.getY(), a2, u2.getY(), a3, u3.getY());
this.z = prototype.linearCombination(a1, u1.getZ(), a2, u2.getZ(), a3, u3.getZ());
}
/** Linear constructor.
* Build a vector from three other ones and corresponding scale factors.
* The vector built will be a1 * u1 + a2 * u2 + a3 * u3
* @param a1 first scale factor
* @param u1 first base (unscaled) vector
* @param a2 second scale factor
* @param u2 second base (unscaled) vector
* @param a3 third scale factor
* @param u3 third base (unscaled) vector
*/
public FieldVector3D(final T a1, final Vector3D u1,
|
|
Hipparchus::Computational Geometry