You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 2, 2021. It is now read-only.
Does someone know how to implement constraints on 2d or 3d geometries.
I have a problem on how to implement a distance constraint between two 3d vectors.
Imagine 2 points in the space
D = 10
P1 = [ 0, 0, 0 ]
P2 = [ 5, 0, 0 ]
How I can add a distance constraint between these two points.
Thanks
My code so far
// Create P1constp1=newPoint3D(0,0,0);// Create edit variablesconstx=newkiwi.Variable('x');consty=newkiwi.Variable('y');constz=newkiwi.Variable('z');this.kiwiSolver.addEditVariable(x,kiwi.Strength.strong);this.kiwiSolver.addEditVariable(y,kiwi.Strength.strong);this.kiwiSolver.addEditVariable(z,kiwi.Strength.strong);this.kiwiSolver.suggestValue(x,v.x);this.kiwiSolver.suggestValue(y,v.y);this.kiwiSolver.suggestValue(z,v.z);this.kiwiSolver.updateVariables();p1.userData['kiwi']={x, y, z}// Create P2constp2=newPoint3D(100,0,0);// Create edit variablesconstx=newkiwi.Variable('x');consty=newkiwi.Variable('y');constz=newkiwi.Variable('z');this.kiwiSolver.addEditVariable(x,kiwi.Strength.strong);this.kiwiSolver.addEditVariable(y,kiwi.Strength.strong);this.kiwiSolver.addEditVariable(z,kiwi.Strength.strong);this.kiwiSolver.suggestValue(x,v.x);this.kiwiSolver.suggestValue(y,v.y);this.kiwiSolver.suggestValue(z,v.z);this.kiwiSolver.updateVariables();p2.userData['kiwi']={x, y, z}constd=Math.sqrt(Math.pow((p1.kiwi.x.value()-p2.kiwi.x.value()),2)+Math.pow((p1.kiwi.y.value()-p2.kiwi.y.value()),2)+Math.pow((p1.kiwi.z.value()-p2.kiwi.z.value()),2));console.log({d});// 100// Here is the problemconstkiwi_distance_constraint=newkiwi.Constraint(Math.pow((p1.kiwi.x-p1.kiwi.x),2)+Math.pow((p1.kiwi.y-p1.kiwi.y),2)+Math.pow((p1.kiwi.z-p1.kiwi.z),2),kiwi.Operator.Eq);this.kiwiSolver.addConstraint(kiwi_distance_constraint);this.kiwiSolver.updateVariables();
The text was updated successfully, but these errors were encountered:
ghost
changed the title
Problem using the kiwi lib for 3d Geometric constraints
Problem using the kiwi for 3d geometric constraints
Mar 9, 2020
Kiwi is linear constraint solver, so it can only handle constraints that are linear equalities or inequalities. Unfortunately, squaring a variable is not linear, so Kiwi can't handle this. You could try using a more expressive constraint solver or changing your constraint definitions so they're linear.
So in geometrical constraints (just in 2D) this means..?
We cannot use kiwi.js. The Cassowary GitHub project's README gives the scope better - these are layout engines for traditional UIs.
I am looking for a CAD-like (2D) constraints engine that would work in a web app (tangents, what-not). Anyone knowing one, or also needing one, please chime in. solver-shootout
@George35mk May I suggest changing the title to "Kiwi.js ... cannot be used in geometric constraints" (or something) since it's a design decision, not really a problem. Also, I nearly missed this because was looking for 2D geometric constraints - the title actually gave me hope since it seemed to imply 2D works.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Does someone know how to implement constraints on 2d or 3d geometries.
I have a problem on how to implement a distance constraint between two 3d vectors.
Imagine 2 points in the space
How I can add a distance constraint between these two points.
Thanks
My code so far
The text was updated successfully, but these errors were encountered: