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

@turf/transform-rotate

Package Overview
Dependencies
Maintainers
9
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/transform-rotate

turf transform-rotate module

  • 7.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
589K
decreased by-3.01%
Maintainers
9
Weekly downloads
 
Created

What is @turf/transform-rotate?

@turf/transform-rotate is a module from the Turf.js library that allows you to rotate geometries by a specified angle around a given pivot point. This can be useful for various geospatial data manipulations, such as aligning features or creating rotated versions of existing geometries.

What are @turf/transform-rotate's main functionalities?

Rotate a Point

This feature allows you to rotate a point geometry by a specified angle. In this example, a point at coordinates [0, 0] is rotated by 45 degrees.

const turf = require('@turf/turf');

const point = turf.point([0, 0]);
const rotatedPoint = turf.transformRotate(point, 45);
console.log(rotatedPoint);

Rotate a Polygon

This feature allows you to rotate a polygon geometry by a specified angle. In this example, a square polygon is rotated by 90 degrees.

const turf = require('@turf/turf');

const polygon = turf.polygon([[
  [0, 0],
  [1, 0],
  [1, 1],
  [0, 1],
  [0, 0]
]]);
const rotatedPolygon = turf.transformRotate(polygon, 90);
console.log(rotatedPolygon);

Rotate around a Custom Pivot

This feature allows you to rotate a geometry around a custom pivot point. In this example, a line is rotated by 45 degrees around the pivot point [1, 1].

const turf = require('@turf/turf');

const line = turf.lineString([[0, 0], [2, 2]]);
const pivot = [1, 1];
const rotatedLine = turf.transformRotate(line, 45, { pivot });
console.log(rotatedLine);

Other packages similar to @turf/transform-rotate

Keywords

FAQs

Package last updated on 09 Aug 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