Kstars

vect.cpp
1/*
2 SPDX-FileCopyrightText: 2012 Andrew Stepanenko
3
4 Modified by Jasem Mutlaq <mutlaqja@ikarustech.com> for KStars:
5 SPDX-FileCopyrightText: 2012 Jasem Mutlaq <mutlaqja@ikarustech.com>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9
10#include "vect.h"
11
12#include <cmath>
13#include <cstdlib>
14
15namespace GuiderUtils
16{
17
18Vector operator^(const Vector &u, const Vector &v)
19{
20 return Vector(u.y * v.z - u.z * v.y, u.z * v.x - u.x * v.z, u.x * v.y - u.y * v.x);
21}
22
23Vector RndVector()
24{
25 Vector v(rand() - 0.5 * RAND_MAX, rand() - 0.5 * RAND_MAX, rand() - 0.5 * RAND_MAX);
26 return Normalize(v);
27}
28
29Vector &Clip(Vector &v)
30{
31 if (v.x < 0.0)
32 v.x = 0.0;
33 else if (v.x > 1.0)
34 v.x = 1.0;
35 if (v.y < 0.0)
36 v.y = 0.0;
37 else if (v.y > 1.0)
38 v.y = 1.0;
39 if (v.z < 0.0)
40 v.z = 0.0;
41 else if (v.z > 1.0)
42 v.z = 1.0;
43
44 return v;
45}
46} // namespace GuiderUtils
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.