untitled notebook

node v10.24.1
version: 1.0.1
endpointsharetweet
var st = require("shapetypes"); // Create a triangle const triangle = new st.Polyline([new st.Point(0, 0), new st.Point(1, 1), new st.Point(2, 0)], true); console.log(triangle.area); // => 1 // Test to see if a point is inside const testPoint = new st.Point(1, 0.5); console.log(triangle.contains(testPoint)); // => True // Move the triangle and see if the point is inside const shifted = triangle.translate(new st.Vector(3, 4)); console.log(shifted.contains(testPoint)); // => False // Create a rectangular polygon const rectangle = new st.Rectangle(st.Plane.worldXY(), 10, 20); const polygon = new st.Polygon(rectangle.toPolyline()); console.log(polygon.area); // => 200 // Cut the triangle from the polygon const result = polygon.difference(triangle); console.log(result[0].area); // => 199
Loading…

no comments

    sign in to comment