import { Vector } from "./Vector";
/** Convenience function for creating a Line, cloning the parameters */
export function createLine(point, direction) {
    return {
        point: Vector.CloneVec3(point),
        direction: Vector.CloneVec3(direction),
    };
}
/** Convenience function for cloning a Line */
export function cloneLine(line) {
    return createLine(line.point, line.direction);
}
/**
 * Get the line that is given by the line segment
 * @param segment
 * @returns {Line}
 */
export function convertLineSegmentToLine(segment) {
    return {
        point: segment.point,
        direction: segment.border,
    };
}
/** Convenience function for creating a Plane, cloning the parameters */
export function createPlane(point, normal) {
    return {
        point: Vector.CloneVec3(point),
        normal: Vector.CloneVec3(normal),
    };
}
/** Convenience function for cloning a Plane */
export function clonePlane(plane) {
    return createPlane(plane.point, plane.normal);
}
/**
 * Get the plane that the segment resides in. The normal of the plane is the cross product of the two border vectors.
 * @param segment
 * @returns {Plane}
 */
export function convertPlaneSegmentToPlane(segment) {
    var normal = Vector.Cross3(segment.borderU, segment.borderV);
    return {
        point: segment.point,
        normal: normal,
    };
}
/**
 * Create a planar (in the xz-plane) plane segment that is given by the lower part of the cube given by the bounds.
 * @param bounds
 * @returns {PlaneSegment}
 */
export function convertBoundsToXZPlaneSegment(bounds) {
    var diameter = Vector.Sub3(bounds.max, bounds.min);
    return {
        point: {
            x: bounds.min.x,
            y: 0,
            z: bounds.min.z,
        },
        borderU: {
            x: diameter.x,
            y: 0,
            z: 0,
        },
        borderV: {
            x: 0,
            y: 0,
            z: diameter.z,
        },
    };
}
/** Convenience function for creating a Transformation, cloning the parameters, rotation must be radinas already */
export function createTransformation(position, rotation) {
    return {
        position: Vector.CloneVec3(position),
        rotation: Vector.CloneVec3(rotation),
    };
}
/** Convenience function for cloning a Transformation */
export function cloneTransformation(transformation) {
    return createTransformation(transformation.position, transformation.rotation);
}
