Giter VIP home page Giter VIP logo

euclid.js's People

Contributors

burimar avatar dependabot[bot] avatar grant-wilson avatar jirihon avatar mend-for-github-com[bot] avatar pjhenning avatar plegner avatar renovate-bot avatar renovate[bot] avatar skim-amplify avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

euclid.js's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • Update dependency tslib to v2.6.2
  • Update Test and Build (esbuild, eslint, eslint-plugin-import)

Detected dependencies

github-actions
.github/workflows/codeql.yml
  • actions/checkout v3
  • github/codeql-action v2
  • github/codeql-action v2
.github/workflows/test.yml
  • actions/checkout v3
  • actions/setup-node v3
  • bahmutov/npm-install v1
npm
package.json
  • @mathigon/core 1.1.10
  • @mathigon/fermat 1.1.9
  • @types/tape 5.6.0
  • @typescript-eslint/eslint-plugin 6.4.0
  • @typescript-eslint/parser 6.4.0
  • esbuild 0.18.17
  • eslint 8.46.0
  • eslint-plugin-import 2.28.0
  • tape 5.6.6
  • ts-node 10.9.1
  • tslib 2.6.1
  • typescript 5.1.6
  • node >=14

  • Check this box to trigger a request for Renovate to run again on this repository

Add a convenient way to set (mutate) the value of a Point

Currently, if I have a circle, there is no way to change the origin of the point to a given point.

There is translate(Point) and shift(x,y), but translate just invokes shift, and it moves the point, not sets it at the new point.

The current solution is to use the verbose constructor and go myCircle = new Circle(new Point(x,y),myCircle.radius).

Either offer a new interface method like Circle.setOrigin(Point) or Circle.setOrigin(x,y) or offer a Point.set(x,y) which will mutate the x and y variables in place.

consider adding `line.points`

This way APIs could accept an interface of { points: Point[] } and be made to work with both Polygon-type shapes and Line-type shapes easily.

This would also allow for destructuring line.points to quickly renaming variables, for example:

// could be...
let [a, b] = line.points

// instead of...
let a = line.p1
let b = line.p2

(I'm just opening issues as I use the library and run into problems or inconveniences, but let me know if you'd prefer I not open these kind of ideas issues.)

Polygon contains method throwing error

(new Polygon([
  new Point(0,0),
  new Point(100,0),
  new Point(100,100),
  new Point(0,100),
])).contains(new Point(50,50));

Throws "Uncaught TypeError: e.p1.equals is not a function" in Polygon.contains

Intersection of ray and polygon contains point that does not lie on the ray

When finding intersections of a ray and a polygon, the result may contain point that does not lie on the ray. Try the following code:

const polygon = new Polygon(new Point(0, 0), new Point(100, 0), new Point(100, 100), new Point(0, 100), new Point(0, 50));
const ray = new Ray(new Point(50, 50), new Point(100, 50));
console.log(intersections(ray, polygon));

The result of the intersections function contains Point(0, 50) which does not lie on the ray.

I think this happens when there is a polygon vertex that lies on a line coincident with the ray. If Point(0, 50) is removed from the polygon, the result is valid.

Incorrect intersections when intersecting vertices

The following produces no intersections but seems like it should:

intersections(
    new Circle( new Point(2, 3), 1),
    new Polygon( new Point(2, 3), new Point(3, 3), new Point(3, 4), new Point(2, 4) 
);

Intersections should be reported at 3, 3 and 2, 4. It seems that when the intersections occur at the polygon's vertices, they are not reported. Is this a bug or have I misunderstood how to use intersections? Thanks!

Finding intersection between LineSegment and Rectangle

Hello, and thanks for this great library!

I wanted to use this library to calculate the intersection between a line segment and a rectangle but was unable to figure out how to do that. The intersections method looked promising, but it does not accept LineSegment or Rectangle as arguments.

In my particular case, it would always just be one intersection because I want to draw a line from the center of one rectangle to the center of another non-overlapping rectangle, but in general, I guess such a function should return a list of potentially more than one intersection.

Line.intercept is wrong

Hi,
I was getting perplexing results using Line and reading the source I realized that the intercept method has a wrong sign.

A possible test case fragment is the following:

    const testline = new Line(
        new Point(1, 1),
        new Point(2, 2)
    );
    console.log('DUA LIPA IS ' + ( testline.intercept === 0 ? 'GORGEOUS' : 'UGLY'));

(of course the intercept should be 0 and Dua is gorgeous)

Trying to locate the error, in file line.ts at line 45 I read
return this.p1.y + this.slope * this.p1.x;

it should be:
return this.p1.y - this.slope * this.p1.x;

Thanks in advance for fixing...

Why is boolean module not exported?

The src/boolean.ts module is the only one which is not exported in src/index.ts. Is there any specific reason for that? Or is it just an accidental omission? I would love to use the module :)

allow contracting segment by different ratio on each side

Right now you can do:

segment.contract(0.25)

But it would be nice to be able to specify the contraction ratio for both the start and end points differently:

segment.contract(0.1, 0.4)

With the default being the same for both.

intersections

I tried following snippet:

const ellipse = new Ellipse(new Point(100, 100), 5, 3, 0);
const pt = new Point(100,100);
console.log("RESULT", intersections(pt, ellipse).length)

Ithe point is inside the ellipse, but the elngth of the intersections() is 0. how to use this correctly?

convert shapes to polygons

First off, this set of libraries is absolutely brilliant, thank you!

I'm playing around with it for some generative art, and wondering if there is a way to convert shapes like circles, ellipses, etc. into polygons. So that I can do things like distort the points, chop them up, smoothing, etc., etc.

It would be great if there was a ellipse.polygon(60) for example which "rasterized" it into a 60-sided polygon.

Extending Rectangle

Hello, some functionality can be added to the Rectangle class:

/**
Restricts the rectangle within another larger rectangle.
{x: -50, y: -50, w: 100, y: 100} restrictWithin {x: 0: y: 0, w: 500, h: 500} -> {x: 0, y: 0, w: 100, y: 100}
*/
restrictWithin(rect: Rectangle): Rectangle;

This also can be added to Circle and Ellipse classes. The method can be overloaded:

restrictWithin(rect: Rectangle): Rectangle;
restrictWithin(rect: Circle): Rectangle;
restrictWithin(rect: Ellipse): Rectangle;

consider adding `Line.interpolate`

In my case I'm trying to quickly interpolate between two line segments. Ideally it would be as easy as Segment.interpolate(a, b, 0.25).

I thought I might be able to use Polygon.interpolate instead, but the TypeScript types complain about that. And using Point.interpolate for the individual points gets tedious. Maybe I'm doing something wrong or missing an easier approach though!

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • Update dependency typescript to v5.4.2
  • Update github/codeql-action action to v3
  • Update typescript-eslint monorepo to v7 (major) (@typescript-eslint/eslint-plugin, @typescript-eslint/parser)

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/codeql.yml
  • actions/checkout v4
  • github/codeql-action v2
  • github/codeql-action v2
.github/workflows/test.yml
  • actions/checkout v4
  • actions/setup-node v3
  • bahmutov/npm-install v1
npm
package.json
  • @mathigon/core 1.1.16
  • @mathigon/fermat 1.1.15
  • @types/tape 5.6.4
  • @typescript-eslint/eslint-plugin 6.21.0
  • @typescript-eslint/parser 6.21.0
  • esbuild 0.20.0
  • eslint 8.56.0
  • eslint-plugin-import 2.29.1
  • tape 5.7.4
  • ts-node 10.9.2
  • tslib 2.6.2
  • typescript 5.3.3
  • node >=16

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Cannot find preset's package (github>whitesource/merge-confidence:beta)

consider allowing `Point` to be expressed as `[number, number]`

I noticed that in the test files this pattern is already used, with inline poly and line helpers defined. It would be really nice to be able to use this out of the box, because defining polygons or lines gets tedious having to do new Point(...), new Point(...), new Point(...) manually.

Some actual code of mine:

let poly = new Polygon(
  new Point(rx, rh),
  new Point(lx, lh),
  new Point(lx, ly),
  new Point(rx, ry)
)

Would be nicely simplified to:

let poly = new Polygon(
  [rx, rh],
  [lx, lh],
  [lx, ly],
  [rx, ry]
)

It seems like this would be a variant of SimplePoint, as a tuple instead of an object?

Scale center point in ellipse

Hello, the method scale on the ellipse does not scale the center point but only the axes. It would be nice if the behavior was the same as in the circle. Many thanks in advance!

  scale(sx: number, sy = sx) {
    return new Ellipse(this.c.scale(sx, sy), this.a * sx, this.b * sy, this.angle);
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.