Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@antv/g-math

Package Overview
Dependencies
Maintainers
64
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/g-math

Geometry util

  • 2.0.3-next.6
  • next
  • Source
  • npm
  • Socket score

Version published
Maintainers
64
Created

What is @antv/g-math?

@antv/g-math is a mathematical utility library designed to support geometric calculations, particularly for graphics and visualization purposes. It provides a range of functions for handling vector, matrix, and geometry operations, making it useful for developers working on graphical applications.

What are @antv/g-math's main functionalities?

Vector Operations

This feature allows you to perform various vector operations such as addition, subtraction, scaling, and normalization. The code sample demonstrates how to add two 2D vectors.

const { vec2 } = require('@antv/g-math');

const v1 = [1, 2];
const v2 = [3, 4];
const result = vec2.add([], v1, v2);
console.log(result); // Output: [4, 6]

Matrix Operations

This feature provides functions for matrix operations such as multiplication, inversion, and transposition. The code sample shows how to multiply two 3x3 matrices.

const { mat3 } = require('@antv/g-math');

const m1 = [1, 0, 0, 0, 1, 0, 0, 0, 1];
const m2 = [2, 0, 0, 0, 2, 0, 0, 0, 2];
const result = mat3.multiply([], m1, m2);
console.log(result); // Output: [2, 0, 0, 0, 2, 0, 0, 0, 2]

Geometry Calculations

This feature includes functions for various geometric calculations like computing the length of a line, finding intersections, and calculating angles. The code sample demonstrates how to calculate the length of a line segment between two points.

const { line } = require('@antv/g-math');

const point1 = [0, 0];
const point2 = [3, 4];
const length = line.length(point1, point2);
console.log(length); // Output: 5

Other packages similar to @antv/g-math

Keywords

FAQs

Package last updated on 13 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc