All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hu.kazocsaba.math.geometry.Segment Maven / Gradle / Ivy

The newest version!
package hu.kazocsaba.math.geometry;

import hu.kazocsaba.math.matrix.Vector;
import hu.kazocsaba.math.matrix.immutable.ImmutableMatrixFactory;
import hu.kazocsaba.math.matrix.immutable.ImmutableVector;

/**
 * A finite line segment. It is specified with its end points.
 * @author Kazó Csaba
 */
public class Segment {
	protected static final double EPS=1e-8;
	
	private final ImmutableVector p1, p2;
	private final ImmutableVector dir;

	Segment(Vector p1, Vector p2) {
		this.p1 = ImmutableMatrixFactory.copy(p1);
		this.p2 = ImmutableMatrixFactory.copy(p2);
		dir = ImmutableMatrixFactory.copy(this.p2.minus(this.p1));
		if (dir.norm()




© 2015 - 2025 Weber Informatics LLC | Privacy Policy