## Prompt

In this reference frame, the spaceship is oriented at [0, 0, 1] relative to the spacecraft. In the reference frame of J2000 the spaceship is oriented at [0.14129425, -0.98905974, 0.04238827]. Find the spacecraft attitude quaternion.

## Background

In mathematics, a quaternion is an extended complex number which helpes to represent mechanics, orientation, rotation, and movement in 3 dimensions. They are often used in computer graphics, computer vision, and applied mathematics and represented in the form a + bi + cj + dk. In that form a, b, c, and d are real numbers and i, j, and k are the basic quaternions.

https://en.wikipedia.org/wiki/Quaternion

https://math.ucr.edu/~huerta/introquaternions.pdf

https://youtu.be/d4EgbgTm0Bg

## Solution

Looking up how to convert two vectors into a quaternion we come across the set of equations

A, B are the given vectors
The form of the answer will be q = (w, x, y, z) <-- NOTE the order


$$N = \frac{A\times B}{||A\times B||}$$

$$\Theta= \arctan{\frac{||A\times B||}{A\cdot B}}$$

$$q = [\cos(\frac{\Theta}{2}), \vec{N}\sin(\frac{\Theta}{2})]$$

So for our solution, A is [0, 0, 1] and B is [0.14129425, -0.98905974, 0.04238827]. First we find N and then Theta and then plug into the equation for q. Once we do that, we input the values into the netcat connection (during the competition) and…

QED
{"ft_lang_label":"__label__en","ft_lang_prob":0.8314544,"math_prob":0.9980227,"size":1264,"snap":"2021-43-2021-49","text_gpt3_token_len":366,"char_repetition_ratio":0.11111111,"word_repetition_ratio":0.009661836,"special_character_ratio":0.31962025,"punctuation_ratio":0.15413533,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9995513,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-12-05T16:25:46Z\",\"WARC-Record-ID\":\"<urn:uuid:926775d2-3ba3-44ff-b1c7-5718a053ee14>\",\"Content-Length\":\"6724\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:e2ccb327-c237-4e2a-8b63-5aa22480e9a9>\",\"WARC-Concurrent-To\":\"<urn:uuid:a06e11af-514e-4a06-8542-05bb7e84e5a5>\",\"WARC-IP-Address\":\"35.185.44.232\",\"WARC-Target-URI\":\"https://ret2rev.dev/post/quaternion/\",\"WARC-Payload-Digest\":\"sha1:6QWE4RDKWKFTPLG6EQ7M3IBVQ5R3MADJ\",\"WARC-Block-Digest\":\"sha1:ZOG7HL2EE3RC4BJXZXRGZAT5IBUEJBXU\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-49/CC-MAIN-2021-49_segments_1637964363215.8_warc_CC-MAIN-20211205160950-20211205190950-00008.warc.gz\"}"}