<commit_before>/*
 * Copyright (c) 2013-2017 <NAME>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include "vimol.h"

vec_t
vec_zero(void)
{
	vec_t vec;

	vec.x = 0.0;
	vec.y = 0.0;
	vec.z = 0.0;

	return (vec);
}

vec_t
vec_xyz(double x, double y, double z)
{
	vec_t vec;

	vec.x = x;
	vec.y = y;
	vec.z = z;

	return (vec);
}

vec_t
vec_random(void)
{
	vec_t vec;
	double rho, phi;

	vec.z = (double)(rand()) / RAND_MAX * 2 - 1.0;

	rho = sqrt(1.0 - vec.z * vec.z);
	phi = (double)(rand()) / RAND_MAX * 2 * PI;

	vec.x = rho * cos(phi);
	vec.y = rho * sin(phi);

	return (vec);
}

vec_t
vec_add(const vec_t *a, const vec_t *b)
{
	vec_t vec;

	vec.x = a->x + b->x;
	vec.y = a->y + b->y;
	vec.z = a->z + b->z;

	return (vec);
}

vec_t
vec_sub(const vec_t *a, const vec_t *b)
{
	vec_t vec;

	vec.x = a->x - b->x;<commit_msg>Use drand48 instead of rand.<commit_after>/*
 * Copyright (c) 2013-2017 <NAME>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include "vimol.h"

vec_t
vec_zero(void)
{
	vec_t vec;

	vec.x = 0.0;
	vec.y = 0.0;
	vec.z = 0.0;

	return (vec);
}

vec_t
vec_xyz(double x, double y, double z)
{
	vec_t vec;

	vec.x = x;
	vec.y = y;
	vec.z = z;

	return (vec);
}

vec_t
vec_random(void)
{
	vec_t vec;
	double rho, phi;

	vec.z = 2.0 * drand48() - 1.0;
	rho = sqrt(1.0 - vec.z * vec.z);
	phi = 2.0 * PI * drand48();
	vec.x = rho * cos(phi);
	vec.y = rho * sin(phi);

	return (vec);
}

vec_t
vec_add(const vec_t *a, const vec_t *b)
{
	vec_t vec;

	vec.x = a->x + b->x;
	vec.y = a->y + b->y;
	vec.z = a->z + b->z;

	return (vec);
}

vec_t
vec_sub(const vec_t *a, const vec_t *b)
{
	vec_t vec;

	vec.x = a->x - b->x;
{'fraction_non_alphanumeric': 0.12354312354312354, 'fraction_numerical': 0.015984015984015984, 'mean_word_length': 3.230985915492958, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2150851', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1134, 'n_words': 417}