Socket
Socket
Sign inDemoInstall

@antv/g-math

Package Overview
Dependencies
2
Maintainers
64
Versions
155
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @antv/g-math

Geometry util


Version published
Weekly downloads
150K
increased by5.68%
Maintainers
64
Created
Weekly downloads
 

Package description

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

Readme

Source

g-math

G 提供几何图形运算的库

安装下载

tnpm i --save @antv/g-math

// 所有的 api 是都这么引入,名字不同而已
import { line } from '@antv/g-math';

const len = line.length(x1, x2, x2, y2);

API 文档

目前使用到的、且推荐使用的 API 文档,不在文档内的不建议使用。

Keywords

FAQs

Last updated on 26 Jun 2023

Did you know?

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc