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 🙏

© 2024 – Pkg Stats / Ryan Hefner

krgeometry

v2.0.4

Published

It contains `Rectangle`, `Box(AABB)`, `Vector3` Just simple geoms for sharing by my packages. It receives parameter as interface for compatibility

Downloads

7

Readme

About this

It contains Rectangle, Box(AABB), Vector3
Just simple geoms for sharing by my packages.
It receives parameter as interface for compatibility

References

export class Rect implements IRect
{
    left:number;
    top:number;
    right:number;
    bottom:number;

    constructor(left:number, top:number, right:number, bottom:number);

    static expandFrom(pos:IVectorXZ, size:number):Rect;

    expand(border:number):Rect;

    intersect(other:IRect):boolean;

    contains(pos:IVectorXZ):boolean;
}

export class Box implements IBox
{
    x1:number, 
    y1:number, 
    z1:number, 
    x2:number, 
    y2:number, 
    z2:number;
    constructor(x1:number, y1:number, z1:number, x2:number, y2:number, z2:number);

    getPoint1():Vector3;
    getPoint2():Vector3;
    expand(border:number):Box;
    moveBy(offset:Vector3):Box;
    intersect(other:IBox):boolean;
    union(other:IBox):Box;
    contains(pos:IVector3):boolean;
    containsXZ(pos:IVectorXZ):boolean;
    
    // make box from IBox
    static make(box:IBox):Box;

    // simmilar with fromVector, but min to x~z1, max to x~z2
    static align(a:IVector3, b:IVector3):Box;
    static expandFrom(pos:IVector3, size:number):Box;
    static fromVector(pos1:IVector3, pos2:IVector3):Box;

}

export class Vector3 implements IVector3
{
    x:number;
    y:number;
    z:number;

    constructor(x:number, y:number, z:number);
    
    normalize():Vector3;
    
    // this == pos
    equals(pos:IVector3):boolean;
    
    // this + pos
    add(pos:IVector3):Vector3;
    
    // this - pos
    sub(pos:IVector3):Vector3;

    // -this
    neg():Vector3;
    
    // this * n
    mul(n:number):Vector3;
    
    // this / n
    div(n:number):Vector3;
    
    floor():Vector3;

    ceil():Vector3;

    round():Vector3;

    length():number;

    // max(abs(x), abs(y), abs(z))
    diaLength():number;

    // (this-v).length()
    distance(v:IVector3):number;

    // distance with xz
    distanceXZ(v:IVectorXZ):number;
 
    // format: (x,y,z)
    toString():string;

    // make Vector3 from IVector3
    static make(pos:IVector3):Vector3;

    // pos1 == pos2
    static equals(pos1:IVector3, pos2:IVector3):boolean;

    // pos1 + pos2
    static add(pos1:IVector3, pos2:IVector3):Vector3;

    // pos1 - pos2
    static sub(pos1:IVector3, pos2:IVector3):Vector3;

    // -v
    static neg(v:IVector3):Vector3;

    // v * n
    static mul(v:IVector3, n:number):Vector3;

    // v / n
    static div(v:IVector3, n:number):Vector3;

    // (v1 - v2).length()
    static distance(v1:IVector3, v2:IVector3):number;

    // format: (x,y,z)
    static toString(pos:IVector3):string;

    static readonly ZERO = new Vector3(0, 0, 0);
    static readonly ONE = new Vector3(1, 1, 1);
    static readonly HALF = new Vector3(0.5, 0.5, 0.5);
    static readonly XZ = new Vector3(1, 0, 1);
    static readonly X = new Vector3(1, 0, 0);
    static readonly Y = new Vector3(0, 1, 0);
    static readonly Z = new Vector3(0, 0, 1);
}

interface IRect
{
    left:number;
    top:number;
    right:number;
    bottom:number;
}

interface IBox
{
    x1:number;
    y1:number;
    z1:number; 
    x2:number;
    y2:number;
    z2:number;
}

interface IVectorXZ
{
    x:number;
    z:number;
}

interface IVector3 
{
    x:number;
    y:number;
    z:number;
}