npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vec3.c

v1.1.1

Published

gl-matrix's vec3, split into smaller pieces, converted to c header files

Readme

gl-vec3

stable

Part of a fork of @toji's gl-matrix to c and split into smaller pieces: this package contains glMatrix.vec3.

Install

npm install vec3.c

Usage

main.c

#include <vec3/type.h>
#include <vec3/create.h>
#include <vec3/set.h>
#include <stdio.h>

int main() {
  vec3 a = vec3_create();
  vec3_set(a, 1.4, 2, -5);
  printf("hello world! (%f, %f, %f)\n", a[0], a[1], a[2]);
}

compiled with gcc main.c -o main -Inode_modules/vec3.c/include

with cmake

__CMakeLists.txt

cmake_minimum_required(VERSION 3.2)
project (vec3-test)
file(GLOB CMAKE_INCLUDES "node_modules/*/CMakeLists.txt")
include(${CMAKE_INCLUDES})
add_executable(main main.c)

API

vec3_add(out:vec3, a:vec3, b:vec3)

Adds two vec3's

vec3_angle(a:vec3, b:vec3)

Get the angle between two 3D vectors

vec3_clone(a:vec3)

Creates a new vec3 initialized with values from an existing vector

vec3_copy(out:vec3, a:vec3)

Copy the values from one vec3 to another

vec3_create()

Creates a new, empty vec3

vec3_cross(out:vec3, a:vec3, b:vec3)

Computes the cross product of two vec3's

vec3_distance(a:vec3, b:vec3)

Calculates the euclidian distance between two vec3's

vec3_divide(out:vec3, a:vec3, b:vec3)

Divides two vec3's

vec3_dot(a:vec3, b:vec3)

Calculates the dot product of two vec3's

vec3_equal(a:vec3, b:vec3)

returns whether the two vectors are near equal

vec3_fromValues(x:Number, y:Number, z:Number)

Creates a new vec3 initialized with the given values

vec3_inverse(out:vec3, a:vec3)

Returns the inverse of the components of a vec3

vec3_length(a:vec3)

Calculates the length of a vec3

vec3_lerp(out:vec3, a:vec3, b:vec3, t:Number)

Performs a linear interpolation between two vec3's

vec3_max(out:vec3, a:vec3, b:vec3)

Returns the maximum of two vec3's

vec3_min(out:vec3, a:vec3, b:vec3)

Returns the minimum of two vec3's

vec3_multiply(out:vec3, a:vec3, b:vec3)

Multiplies two vec3's

vec3_negate(out:vec3, a:vec3)

Negates the components of a vec3

vec3_normalize(out:vec3, a:vec3)

Normalize a vec3

vec3_random(out:vec3, [scale]:Number)

Generates a random vector with the given scale

vec3_rotateX(out:vec3, a:vec3, b:vec3, c:Number)

Rotate a 3D vector around the x-axis

vec3_rotateY(out:vec3, a:vec3, b:vec3, c:Number)

Rotate a 3D vector around the y-axis

vec3_rotateZ(out:vec3, a:vec3, b:vec3, c:Number)

Rotate a 3D vector around the z-axis

vec3_scale(out:vec3, a:vec3, b:Number)

Scales a vec3 by a scalar number

vec3_scaleAndAdd(out:vec3, a:vec3, b:vec3, scale:Number)

Adds two vec3's after scaling the second operand by a scalar value

vec3_set(out:vec3, x:Number, y:Number, z:Number)

Set the components of a vec3 to the given values

vec3_squaredDistance(a:vec3, b:vec3)

Calculates the squared euclidian distance between two vec3's

vec3_squaredLength(a:vec3)

Calculates the squared length of a vec3

vec3_subtract(out:vec3, a:vec3, b:vec3)

Subtracts vector b from vector a

vec3_transformMat3(out:vec3, a:vec3, m:mat4)

Transforms the vec3 with a mat3.

vec3_transformMat4(out:vec3, a:vec3, m:mat4)

Transforms the vec3 with a mat4. 4th vector component is implicitly '1'

vec3_transformQuat(out:vec3, a:vec3, q:quat)

Transforms the vec3 with a quat

License

zlib. See LICENSE.md for details.