The maths, as you write it
a + b, a - b, -a, 2 * a, a / 4, a .dot. b, a .cross. b, a .paral. n, a .ortho. n, R .matrix. a: a scalar of any integer or real kind on either side, converted for you.
Arithmetic
One vector type, written as you write the maths: a + b, 2 * a, a .dot. b, a .cross. b. Lengths, angles, face normals, distances, projections, rotations and mirrors, in single, double or quadruple precision, on whole arrays at once, and inside an OpenACC kernel.
The tetrahedron of the tutorial: its outward face normals, a point q and its foot on the slanted face. Every figure of these pages is computed by VecFor, projected onto the page with its own dot product, and drawn by foresight.
A triangle in space, its normal and area, an angle, a point above it, its distance and its foot: this is a whole program.
program quickstart
!< Quick start: a triangle in space, its normal and area, a point above it, its distance and its foot.
use penf, only : R8P
use vecfor, only : angle, ex, ey, ez, face_normal3, vector
implicit none
type(vector) :: a, b, c ! the corners of a triangle
type(vector) :: n ! its normal
type(vector) :: q ! a point
type(vector) :: foot ! its projection onto the plane of the triangle
a = ex
b = ey
c = ez
n = face_normal3(pt1=a, pt2=b, pt3=c) ! as long as the triangle is large
call n%printf(prefix='normal = ')
print '(A,F7.4)', 'area = ', n%normL2()
print '(A,F7.4)', 'angle = ', angle(b - a, c - a) * 180 / acos(-1._R8P)
q = 0.8_R8P * ex + 0.6_R8P * ey + 0.8_R8P * ez
print '(A,F7.4)', 'distance = ', q%distance_to_plane(pt1=a, pt2=b, pt3=c)
foot = q%projection_onto_plane(pt1=a, pt2=b, pt3=c)
print '(A,3F7.4)', 'foot = ', foot%x, foot%y, foot%z
endprogram quickstart$ quickstart
normal = +0.5, +0.5, +0.5
area = 0.8660
angle = 60.0000
distance = 0.6928
foot = 0.4000 0.2000 0.4000Each figure is the output of a program of the docs; the title leads to the recipe or the chapter that computes it.
Learn VecFor step by step in the tutorial, find quick answers in the cookbook, look up every operator and method in the reference.
Contributions are welcome — see the Contributing page.