"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Vector_1 = require("./Vector");
/** Convenience function for creating a Line, cloning the parameters */
function createLine(point, direction) {
    return {
        point: Vector_1.Vector.CloneVec3(point),
        direction: Vector_1.Vector.CloneVec3(direction),
    };
}
exports.createLine = createLine;
/** Convenience function for cloning a Line */
function cloneLine(line) {
    return createLine(line.point, line.direction);
}
exports.cloneLine = cloneLine;
/**
 * Get the line that is given by the line segment
 * @param segment
 * @returns {Line}
 */
function convertLineSegmentToLine(segment) {
    return {
        point: segment.point,
        direction: segment.border,
    };
}
exports.convertLineSegmentToLine = convertLineSegmentToLine;
/** Convenience function for creating a Plane, cloning the parameters */
function createPlane(point, normal) {
    return {
        point: Vector_1.Vector.CloneVec3(point),
        normal: Vector_1.Vector.CloneVec3(normal),
    };
}
exports.createPlane = createPlane;
/** Convenience function for cloning a Plane */
function clonePlane(plane) {
    return createPlane(plane.point, plane.normal);
}
exports.clonePlane = clonePlane;
/**
 * 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}
 */
function convertPlaneSegmentToPlane(segment) {
    var normal = Vector_1.Vector.Cross3(segment.borderU, segment.borderV);
    return {
        point: segment.point,
        normal: normal,
    };
}
exports.convertPlaneSegmentToPlane = convertPlaneSegmentToPlane;
/**
 * 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}
 */
function convertBoundsToXZPlaneSegment(bounds) {
    var diameter = Vector_1.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,
        },
    };
}
exports.convertBoundsToXZPlaneSegment = convertBoundsToXZPlaneSegment;
/** Convenience function for creating a Transformation, cloning the parameters, rotation must be radinas already */
function createTransformation(position, rotation) {
    return {
        position: Vector_1.Vector.CloneVec3(position),
        rotation: Vector_1.Vector.CloneVec3(rotation),
    };
}
exports.createTransformation = createTransformation;
/** Convenience function for cloning a Transformation */
function cloneTransformation(transformation) {
    return createTransformation(transformation.position, transformation.rotation);
}
exports.cloneTransformation = cloneTransformation;
