Skip to content

szaghi/VecFor

Repository files navigation

VecFor

3D Cartesian vector algebra for Fortran

a pure Fortran 2003+ OOP library for vectorial calculus in a three-dimensional frame of reference.

GitHub tag GitHub issues CI coverage License

📐 Rich Operator Set
+, -, *, /, .cross., .dot., .paral., .ortho. — full Cartesian algebra in operator notation
🔢 Mixed-Kind Operands
Vector OP scalar for any integer or real PENF kind, resolved at compile time with no runtime overhead
📏 Geometry Methods
angle, rotate, mirror, face_normal3/4, distance_to_line, distance_to_plane, projection_onto_plane
🎚️ Multi-Precision
vector_R4P, vector_R8P (default), vector_R16P — all re-exported from a single use vecfor
Pure & Elemental
All procedures are pure or elemental — thread-safe, no side effects
🔓 Multi-licensed
GPL v3 · BSD 2/3-Clause · MIT
📦 Multiple build systems
fpm, FoBiS, CMake, Make
📖 OOP / TDD designed
One derived type, comprehensive automated doctests

For full documentations (guide, tutorial, examples, etc...) see the VecFor website.


Authors

Contributions are welcome — see the Contributing page.

Copyrights

This project is distributed under a multi-licensing system:

Anyone interested in using, developing, or contributing to VecFor is welcome — pick the license that best fits your needs.


Quick start

Import VecFor, build vectors from the built-in Cartesian versors, and perform algebra:

use vecfor
implicit none
type(vector) :: point1, point2, distance

point1 = 1 * ex                  ! ex, ey, ez are the Cartesian unit versors
point2 = 1 * ex + 2 * ey

distance = point2 - point1       ! [0, 2, 0]
call distance%print              ! Component y +2.000...
print *, distance%normL2()       ! 2.0

Vectorial operators:

use vecfor
use penf, only: R8P
implicit none
type(vector) :: v1, v2, cross
real(R8P)    :: dot

v1 = ex
v2 = ex + 2 * ey
cross = v1 .cross. v2   ! [0, 0, 2]
dot   = v1 .dot.   v2   ! 1.0

Install

FoBiS

Standalone — clone, build, and install in one command:

FoBiS.py install szaghi/VecFor -mode static-gnu
FoBiS.py install szaghi/VecFor -mode static-gnu --prefix /path/to/prefix

As a project dependency — declare VecFor in your fobos and run fetch:

[dependencies]
deps_dir = src/third_party
VecFor   = https://github.com/szaghi/VecFor
FoBiS.py fetch           # fetch and build
FoBiS.py fetch --update  # re-fetch and rebuild

fpm

Add to your fpm.toml:

[dependencies]
VecFor = { git = "https://github.com/szaghi/VecFor" }
fpm build
fpm test

CMake

cmake -B build && cmake --build build

Makefile

make              # static library
make TESTS=yes    # build and run tests

About

Vector algebra class for Fortran poor people

Topics

Resources

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors