//[astronomy](../../../index.md)/[io.github.cosinekitty.astronomy](../index.md)/[Vector](index.md) # Vector data class [Vector](index.md)(x: [Double](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html), y: [Double](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html), z: [Double](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html), t: [Time](../-time/index.md)) A 3D Cartesian vector whose components are expressed in Astronomical Units (AU). ## Constructors | | | |---|---| | [Vector](-vector.md)
fun [Vector](-vector.md)(x: [Double](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html), y: [Double](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html), z: [Double](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html), t: [Time](../-time/index.md)) | ## Functions | Name | Summary | |---|---| | [angleWith](angle-with.md)
fun [angleWith](angle-with.md)(other: [Vector](index.md)): [Double](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html)
Calculates the angle in degrees (0..180) between two vectors. | | [div](div.md)
operator fun [div](div.md)(denom: [Double](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html)): [Vector](index.md)
Divides a vector by a scalar. | | [dot](dot.md)
infix fun [dot](dot.md)(other: [Vector](index.md)): [Double](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html)
Takes the dot product of two vectors. | | [length](length.md)
fun [length](length.md)(): [Double](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html)
The total distance in AU represented by this vector. | | [minus](minus.md)
operator fun [minus](minus.md)(other: [Vector](index.md)): [Vector](index.md)
Subtracts one vector from another. Both operands must have identical times. | | [plus](plus.md)
operator fun [plus](plus.md)(other: [Vector](index.md)): [Vector](index.md)
Adds two vectors. Both operands must have identical times. | | [toEquatorial](to-equatorial.md)
fun [toEquatorial](to-equatorial.md)(): [Equatorial](../-equatorial/index.md)
Given an equatorial vector, calculates equatorial angular coordinates. | | [toHorizontal](to-horizontal.md)
fun [toHorizontal](to-horizontal.md)(refraction: [Refraction](../-refraction/index.md)): [Spherical](../-spherical/index.md)
Converts Cartesian coordinates to horizontal coordinates. | | [toObserver](to-observer.md)
fun [toObserver](to-observer.md)(equator: [EquatorEpoch](../-equator-epoch/index.md)): [Observer](../-observer/index.md)
Calculates the geographic location corresponding to a geocentric equatorial vector. | | [toSpherical](to-spherical.md)
fun [toSpherical](to-spherical.md)(): [Spherical](../-spherical/index.md)
Converts Cartesian coordinates to spherical coordinates. | | [unaryMinus](unary-minus.md)
operator fun [unaryMinus](unary-minus.md)(): [Vector](index.md)
Negates a vector; the same as multiplying the vector by the scalar -1. | | [withTime](with-time.md)
fun [withTime](with-time.md)(time: [Time](../-time/index.md)): [Vector](index.md)
Creates a new vector with the same coordinates but a different time. | ## Properties | Name | Summary | |---|---| | [t](t.md)
val [t](t.md): [Time](../-time/index.md)
The date and time at which this vector is valid. | | [x](x.md)
val [x](x.md): [Double](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html)
A Cartesian x-coordinate expressed in AU. | | [y](y.md)
val [y](y.md): [Double](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html)
A Cartesian y-coordinate expressed in AU. | | [z](z.md)
val [z](z.md): [Double](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html)
A Cartesian z-coordinate expressed in AU. |