I love it when a geometry library has options like rotate towards, Vector3 to
euler angles, Distance, lerp, and similar options. Is there any chance you
could add these functions or an openscad file because they are not easy to
code them to openscad, it's would be awesome to find a heavy geom functions
library and just copy it into openscad engine:
Vector3 modules
Angle Returns the angle in degrees between from and to.
ClampMagnitude Returns a copy of vector with its magnitude clamped to
maxLength.
Cross Cross Product of two vectors.
Distance Returns the distance between a and b.
Dot Dot Product of two vectors.
Lerp Linearly interpolates between two vectors.
LerpUnclamped Linearly interpolates between two vectors.
Max Returns a vector that is made from the largest components of two
vectors.
Min Returns a vector that is made from the smallest components of two
vectors.
MoveTowards Moves a point current in a straight line towards a target point.
Normalize
OrthoNormalize Makes vectors normalized and orthogonal to each other.
Project Projects a vector onto another vector.
ProjectOnPlane Projects a vector onto a plane defined by a normal orthogonal
to the plane.
Reflect Reflects a vector off the plane defined by a normal.
RotateTowards Rotates a vector current towards target.
Scale Multiplies two vectors component-wise.
Slerp Spherically interpolates between two vectors.
SlerpUnclamped Spherically interpolates between two vectors.
SmoothDamp Gradually changes a vector towards a desired goal over time.
--
View this message in context: http://forum.openscad.org/Can-you-suggest-some-libraries-of-standard-geometry-conversions-tp13900.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
A couple of the basics are there - https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#Mathematical_Operators https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#Mathematical_Operators
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#Vector_Dot-Product_Operator https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#Vector_Dot-Product_Operator
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#cross https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#cross
I had included matrix inverse operation from the eigen library in my first attempt at including matrix operation support in OpenSCAD, but that got lost thru the major Value rewrite/re-architecting that happened a couple of years ago.
Andrew.
On Sep 19, 2015, at 10:38 AM, ufomorace ant.stewart@yahoo.com wrote:
I love it when a geometry library has options like rotate towards, Vector3 to
euler angles, Distance, lerp, and similar options. Is there any chance you
could add these functions or an openscad file because they are not easy to
code them to openscad, it's would be awesome to find a heavy geom functions
library and just copy it into openscad engine:
Vector3 modules
Angle Returns the angle in degrees between from and to.
ClampMagnitude Returns a copy of vector with its magnitude clamped to
maxLength.
Cross Cross Product of two vectors.
Distance Returns the distance between a and b.
Dot Dot Product of two vectors.
Lerp Linearly interpolates between two vectors.
LerpUnclamped Linearly interpolates between two vectors.
Max Returns a vector that is made from the largest components of two
vectors.
Min Returns a vector that is made from the smallest components of two
vectors.
MoveTowards Moves a point current in a straight line towards a target point.
Normalize
OrthoNormalize Makes vectors normalized and orthogonal to each other.
Project Projects a vector onto another vector.
ProjectOnPlane Projects a vector onto a plane defined by a normal orthogonal
to the plane.
Reflect Reflects a vector off the plane defined by a normal.
RotateTowards Rotates a vector current towards target.
Scale Multiplies two vectors component-wise.
Slerp Spherically interpolates between two vectors.
SlerpUnclamped Spherically interpolates between two vectors.
SmoothDamp Gradually changes a vector towards a desired goal over time.
--
View this message in context: http://forum.openscad.org/Can-you-suggest-some-libraries-of-standard-geometry-conversions-tp13900.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
On 09/19/2015 04:38 PM, ufomorace wrote:
Is there any chance you could add these functions or an openscad
file because they are not easy to code them to openscad,
What about starting with some of the easier functions, putting
those in a file on github (or similar service) and then start
discussing how to go from there step by step?
Note that if the target would be to include it into OpenSCAD
distribution (which would be awesome), the license should be
clarified from the start.
When the question is "could someone please write a huge complicated
library I'd like to use" the number of people who identify with
"someone" is usually not very high.
ciao,
Torsten.
Not a single library, but a number of libs and designs with
some quite interesting functions:
http://www.thingiverse.com/WilliamAAdams/designs
e.g.:
Geodesic Maths for OpenScad - v0.1
http://www.thingiverse.com/thing:10540
Quaternions for OpenScad
http://www.thingiverse.com/thing:10249
ciao,
Torsten.
I've been working on a lib that can do a lot of what you describe, but it is
not ready for release yet :(
I'm gonna make some remark going through your list:
ufomorace wrote
Vector3 modules // Vector3 in unity seems to have properties. OpenScad
can't do properties. Besides, a vector and a point have the same
representation, [x,y,z], so I simply treat them as points. Whatever you
want to do with that vector, you have to use a function or module: do_what
( vector ).
Angle Returns the angle in degrees between from and to. // Got this
ClampMagnitude Returns a copy of vector with its magnitude clamped to
maxLength. // Got this
Cross Cross Product of two vectors. // openscad can do this
Distance Returns the distance between a and b. // Got this
Dot Dot Product of two vectors. // openscad can do this
Lerp Linearly interpolates between two vectors. // Got this
LerpUnclamped Linearly interpolates between two vectors. // Got this
Max Returns a vector that is made from the largest components of two
vectors. // [ for(i=[0:2]) max( v1[i], v2[i] ) ]
Min Returns a vector that is made from the smallest components of two
vectors. // [ for(i=[0:2]) min( v1[i], v2[i] ) ]
MoveTowards Moves a point current in a straight line towards a target
point. // Got this
Normalize // Openscad can do this
OrthoNormalize Makes vectors normalized and orthogonal to each other. //
Not quite understand but shouldn't be hard
Project Projects a vector onto another vector. // Got this
ProjectOnPlane Projects a vector onto a plane defined by a normal
orthogonal to the plane. // Got this
Reflect Reflects a vector off the plane defined by a normal. // Got this
RotateTowards Rotates a vector current towards target. // Got this
Scale Multiplies two vectors component-wise. // ??
Slerp Spherically interpolates between two vectors. // Got this (sort of)
SlerpUnclamped Spherically interpolates between two vectors. // Got this
(sort of)
SmoothDamp Gradually changes a vector towards a desired goal over time. //
not this
$ Runsun Pan, PhD
$ -- libs: doctest , faces ( git ), offliner ( git );
tips: hash( 1 , 2 ), sweep , var
$ -- Linux Mint 17.1 Rebecca x64 + OpenSCAD 2015.03.15/2015.04.01.nightly
--
View this message in context: http://forum.openscad.org/Can-you-suggest-some-libraries-of-standard-geometry-conversions-tp13900p13904.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
ufomorace wrote
Lerp Linearly interpolates between two vectors.
LerpUnclamped Linearly interpolates between two vectors.
For this, check out my code and it's result here:
http://forum.openscad.org/Irregular-mesh-generated-tp13765p13779.html
http://forum.openscad.org/Irregular-mesh-generated-tp13765p13779.html
$ Runsun Pan, PhD
$ -- libs: doctest , faces ( git ), offliner ( git );
tips: hash( 1 , 2 ), sweep , var
$ -- Linux Mint 17.1 Rebecca x64 + OpenSCAD 2015.03.15/2015.04.01.nightly
--
View this message in context: http://forum.openscad.org/Can-you-suggest-some-libraries-of-standard-geometry-conversions-tp13900p13905.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Hiya,
Thanks Andrew I was attempting to figure out vector3 to euler angles and
matrix conversions and i think i had found some previous matrix conversion
files of yours, and that's the aim of the topic, to be able to skip on the
time searching various libraries and converting C++ code to openscad code,
only to attempt a whimsical idea for a geometry experiment.
Torsten, Thanks for the resources, i'll add them onto the wiki maths
reference when i have a moment free. functions like Distance and vector3 to
euler angles are something everyone would know if they are available, it
saves so much time! I could find 15 of them in C++ and it would take me a
couple of hours to write them to a list and then 2 days to write them to
.scad code, so for that reason it would make sense, if there are 20-30
desireable geometry conversions to do it is much faster to slipstream a
library into the source code.
Runsun nice work it is very cool to have similar maths available when
searching for ways of doing a geometry task, because it can be various
different options, it makes a more powerful control over the pc to have
maths expressions always available. I will write a list of all the functions
i use often in C# here and from the previously suggested resources, matrix
quaternion vector conversions and rotations they are standard reference for
everyone?!?
--
View this message in context: http://forum.openscad.org/Can-you-suggest-some-libraries-of-standard-geometry-conversions-tp13900p13936.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
I will collect as many simple maths functions as i can and will write them to
the top of this page in .scad form, feel free to post any 3d manip functions
i will make a neat library in the OP.
Because of the lack of rewriteable variables and the translation of code it
would take a lot longer to make and verify a 3d functions library in .scad
language than just copy pasting a c++ one. for example lookat function, i
have cubes arranged in a sphere around origin and want to make them all look
at the centre, or any other random point.
here is look at:
// C++ code
// this code assumes the camera is initially looking towards (1,0,0)
positive z direction
// if you want the initial direction to be along the x or y coordinates then
try swapping
// the order when setting the components
// dir = target direction
// up = a vector which is perpendicular to the camera axis
void LookAt(const vector3& dir, const vector3& up, matrix33& m) {
vector3 z(dir);
z.norm();
vector3 x( up * z ); // x = up cross z
x.norm();
vector3 y( z * x ); // y = z cross x
m.set_components(x,y,z );
}
first we have to write the matrix of any objects that need to be looked at:
have to convert position where objects are created to a matrix version using
this:
// Extract new local position
Vector3 position = m.GetColumn(3);
// Extract new local rotation
Quaternion rotation = Quaternion.LookRotation(
m.GetColumn(2),
m.GetColumn(1)
);
// Extract new local scale
Vector3 scale = new Vector3(
m.GetColumn(0).magnitude,
m.GetColumn(1).magnitude,
m.GetColumn(2).magnitude
);
--
View this message in context: http://forum.openscad.org/Can-you-suggest-some-libraries-of-standard-geometry-conversions-tp13900p14038.html
Sent from the OpenSCAD mailing list archive at Nabble.com.