package ru.dbotthepony.kstarbound.math.vector

import ru.dbotthepony.kstarbound.math.vector.Vector2d
import ru.dbotthepony.kstarbound.math.vector.Vector2f
import ru.dbotthepony.kstarbound.math.vector.Vector3d
import ru.dbotthepony.kstarbound.math.vector.Vector3f
import ru.dbotthepony.kstarbound.math.vector.Vector4d
import ru.dbotthepony.kstarbound.math.vector.Vector4f

/**
 * Linear interpolation between [a] and [b] by [t]
 */
fun linearInterpolation(t: Float, a: Vector2f, b: Vector2f): Vector2f {
	if (t <= 0f)
		return a
	else if (t >= 1f)
		return b

	return a + (b - a) * t
}

/**
 * Linear interpolation between [a] and [b] by [t]
 */
fun linearInterpolation(t: Float, a: Vector3f, b: Vector3f): Vector3f {
	if (t <= 0f)
		return a
	else if (t >= 1f)
		return b

	return a + (b - a) * t
}

/**
 * Linear interpolation between [a] and [b] by [t]
 */
fun linearInterpolation(t: Float, a: Vector4f, b: Vector4f): Vector4f {
	if (t <= 0f)
		return a
	else if (t >= 1f)
		return b

	return a + (b - a) * t
}


/**
 * Linear interpolation between [a] and [b] by [t]
 */
fun linearInterpolation(t: Double, a: Vector2d, b: Vector2d): Vector2d {
	if (t <= 0.0)
		return a
	else if (t >= 1.0)
		return b

	return a + (b - a) * t
}

/**
 * Linear interpolation between [a] and [b] by [t]
 */
fun linearInterpolation(t: Double, a: Vector3d, b: Vector3d): Vector3d {
	if (t <= 0.0)
		return a
	else if (t >= 1.0)
		return b

	return a + (b - a) * t
}

/**
 * Linear interpolation between [a] and [b] by [t]
 */
fun linearInterpolation(t: Double, a: Vector4d, b: Vector4d): Vector4d {
	if (t <= 0.0)
		return a
	else if (t >= 1.0)
		return b

	return a + (b - a) * t
}
