Last active
August 29, 2015 14:05
-
-
Save Morgul/49adeef1cd34dc9fe7ee to your computer and use it in GitHub Desktop.
[Proposal] Vector Library for Erlang, backed by Bullet Physics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% @doc A module for working with vectors. | |
-module(vector). | |
% ------------------------------------------------------------------------- | |
-export([]). | |
-record(vector, { | |
x :: float(), | |
y :: float(), | |
z :: float() | |
}). | |
% ------------------------------------------------------------------------- | |
% btVector3 API | |
% ------------------------------------------------------------------------- | |
%% @doc Returns the length of the vector. | |
-spec length(Vec :: #vector{}) -> float(). | |
length(Vec) -> | |
ok. | |
%% @doc Returns the length of the vector, squared. | |
-spec length_squared(Vec :: #vector{}) -> float(). | |
length_squared(Vec) -> | |
ok. | |
%% @doc Return the distance between the ends of this and another vector. | |
%% This is symantically treating the vector like a point. | |
-spec distance(OtherVec :: #vector{}, ThisVec :: #vector{}) -> float(). | |
distance(OtherVec, ThisVec) -> | |
ok. | |
%% @doc Return the distance between the ends of this and another vector, squared. | |
%% This is symantically treating the vector like a point. | |
-spec distance_squared(OtherVec :: #vector{}, ThisVec :: #vector{}) -> float(). | |
distance_squared(OtherVec, ThisVec) -> | |
ok. | |
is_zero(Vec) -> | |
ok. | |
fuzzy_zero(Vec) -> | |
ok. | |
add(OtherVec, ThisVec) -> | |
ok. | |
subtract(OtherVec, ThisVec) -> | |
ok. | |
multiply(OtherVec, ThisVec) -> | |
ok. | |
divide(OtherVec, ThisVec) -> | |
ok. | |
is_equal(OtherVec, ThisVec) -> | |
ok. | |
dot(OtherVec, ThisVec) -> | |
ok. | |
normalize(Vec) -> | |
ok. | |
rotate(Axis, Angle, Vec) -> | |
ok. | |
angle(OtherVec, ThisVec) -> | |
ok. | |
absolute(Vec) -> | |
ok. | |
cross(OtherVec, ThisVec) -> | |
ok. | |
triple(Vec1, Vec2, ThisVec) -> | |
ok. | |
lerp(OtherVec, Ratio, ThisVec) -> | |
ok. | |
max_axis(Vec) -> | |
ok. | |
min_axis(Vec) -> | |
ok. | |
set_max(OtherVec, ThisVec) -> | |
ok. | |
set_min(OtherVec, ThisVec) -> | |
ok. | |
% ------------------------------------------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment