Show messages:
1-11
…
372-391
392-411
412-431
432-451
452-471
472-491
492-511
…
632-639
From: pressure (PEER)
Brian,
See attached. The surface is spherical. I want to get the point that's marked with a pointObject. In other words, the center of curvature.
Attachments:
sphere_center.3dm
From: bemfarmer
For a Spherical cap:
https://en.wikipedia.org/wiki/Spherical_cap
Let d = (r-h)
d = sqrt(r*r - a*a)
r = (a*a + h*h) / 2*h
theta = arcsin(a/r)
- Brian
Hasty trig math, check for errors:-)
From: Michael Gibson
Hi Peer,
> I don't understand what this means. To me a conic section means a curve.
Yes you're correct, sorry I used the wrong term there.
> I guess I could draw 2 pointObjects snapped to the surface of the face, dropPoint to
> get uv coordinate points, evaluate normal at each of the uv points, extend a line
> along each normal, and find the intersection = center. Is that the best way?
Yes, intersecting 2 surface normals would be a way to get the center currently.
You can get 2 UV coordinates using the domain boundaries instead of dropping points.
var minpt = face.domainMin; // 2d point for UV domain min corner.
var maxpt = face.domainMax; // 2d point for UV domain max corner.
Just don't use the min and the max both directly because those will be at each pole and those normals will be colinear.
So maybe something like 1/3 between them for one point and 2/3 between for the other one.
- Michael
From: pressure (PEER)
Thanks Michael. domainMin/Max sound very promising. I'll give that approach a try.
From: bemfarmer
A way to get two points on the surface:
Select the edge of the cap.
Run MarkCurveEnd for point 1
Run MarkCurveMidpoint for point 2
Run some script to get the two normals, and intersect.
The two normals can be manually found.
So is a utility script to be created for the 2 UV coordinates method?
- Brian
From: bemfarmer
Array endpoint of edge to edge curve, with 4 points.
This establishes two perpendicular lines, and a plane.
The normal to the two lines, through the Center point of line through endpoint and midpoint, passes through the apex of the cap, and the centerpoint of the sphere, and allows calculation of "h", "a", and "r".
https://web.ma.utexas.edu/users/m408m/Display12-5-4.shtml#:~:text=The%20normal%20to%20the%20plane,%C3%97(s%E2%88%92b).
Enough math for tonight.
- Brian
From: Michael Gibson
Hi Brian,
re:
> So is a utility script to be created for the 2 UV coordinates method?
Something like this:
code:
var face;
<... get face object ...>
var uv_min = face.domainMin;
var uv_max = face.domainMax;
function Lerp( t, low, high )
{
return low + ((high - low) * t);
}
function LerpUVPoint( t, ptA, ptB )
{
return { x : Lerp( t, ptA.x, ptB.x), y : Lerp( t, ptA.y, ptB.y ) }
}
var uv_a = LerpUVPoint( 0.3, uv_min, uv_max );
var uv_b = LerpUVPoint( 0.6, uv_min, uv_max );
var factory = moi.command.createFactory( 'point' );
factory.setInput( 0, face.evaluatePoint( uv_a ) );
factory.commit();
From: bemfarmer
Thank you Michael
The _ChangeHole script has Face selection code...
I might play with it after work...
- Brian
From: Elang
Hello, Michael.
Would you kindly include SPIRO PATH to Moi v5's Draw Curve > Spiro Path? It is similar to the one in InkScape. Since it guarantees the formation of lovely curves, I think it would greatly strengthen Moi.
I ask because I frequently utilize Moi to "trace" bitmap images, notably logos, into vectors, which are then transformed into 3D logos.
Thank you very much.
From: Michael Gibson
Hi Elang, previously due to licensing and patents it was only possible to include Spiro in open source programs, not in commercial programs like MoI.
I think the licensing has changed though and it may be possible to use it outside of open source now.
I'll put it on my list to investigate, it might not make it in for the v5 release though.
- Michael
From: bemfarmer
There is a Clothoid script.
For "tracing", the Clothoid script can be used.
But using a pair of tangents, and the Blend command works very well, perhaps better than the Clothoid method, IMHO.
(repeat Blend with multiple tangent pairs.) The History effect on Blend is also handy.
https://raphlinus.github.io/curves/2019/05/10/spline-licensing-update.html
The Raph Levien spiro patent was placed in public domain ~ 2019, per above link. Legalities?
There was talk on the forum many years ago...
- Brian
https://graphicdesign.stackexchange.com/questions/76007/what-is-the-math-governing-the-shape-of-inkscapes-spiro-paths
As I recall, the Clothoid script was based upon a Paper, and used advanced math and programming, even calculus programming...
From: making5tuff
If we're talking wish list items, I would love expanded formatting distance display. I use Moi for woodworking, and it's easiest when working with tape measures and other woodworking rulers to stay in inches, with fractions.
It'd be great to have the formatting distance displace to have Decimal, Feet & Inches and Inches. Or "Decimal with Fractions".
From: blackboard
Hi, maybe u can add to moi opportunity to drag points of solids like in rhinoceros?
From: Michael Gibson
Hi blackboard,
re:
> maybe u can add to moi opportunity to drag points of solids like in rhinoceros?
It usually doesn't work very well to try and do this with solids made up of trimmed NURBS surfaces. There are lots of problems with this feature area in Rhino where it generates messy results in many cases.
If you want to model by dragging around surface points it's better to do sub-d modeling for that rather than CAD modeling.
- Michael
From: Larry Fahnoe (FAHNOE)
Forgive me Master for I know not what I ask… ;-}
An MoI object dumper usable in a script. Maybe akin to perl’s Data::Dumper, something that returns a string describing the MoI object passed? Perhaps a simplified description along the lines of the Type information provided by clicking on the UI’s Details...? Recursive object dumping would be nice but probably too much to hope for. Thinking specifically about descriptions of MoI's objects, not a generalized javascript object dump.
moi.ui.alert( moi.dump( obj));
When I’m writing and debugging a script, a common challenge is figuring out what I’ve just done to abuse MoI’s object model & why my attempts to get an object's property or method to work are blowing up--typically because I've used an object incorrectly. When things go awry I start by looking at what I've just added, and then assuming it isn't a syntax error, I begin adding moi.ui.alert() messages and wrapping suspect blocks in try {} catch( e) { moi.ui.alert( 'error: ' + e) }. Having the ability to dump object information would be another very useful assist I think.
--Larry
From: Michael Gibson
Hi Larry, re: object dump method - if you could give a more complete spec of exactly what output you would want that would help.
- Michael
From: Larry Fahnoe (FAHNOE)
> Hi Larry, re: object dump method - if you could give a more complete spec of exactly what output you would want that would help.
Hi Michael,
Not knowing what’s inside "the box" makes it challenging to provide a more complete spec, hence my explanation of how I’d make use of whatever info could reasonably be provided. So, guessing at the box’s contents, perhaps something along the lines of:
code:
object type: MoI object class/subclass name, e.g. ObjectList or curve
object properties:
name: value (perhaps RO, or RW)
[…]
object methods: (this is maybe too much to suggest)
name: brief parameter description
[…]
I’m thinking that this sort of information would be used in the context of moi.ui.alert() or moi.log() and would be intended to help someone writing a script diagnose issues while debugging. I think this helps to address a class of mistakes that arise from a misunderstanding of the object model. Perhaps there are other attributes that might make sense in this context.
As an example of where a dump tool might help: I kept getting “calculation failed” from my attempts to use the offset factory and after a bunch of flailing about the lightbulb finally came on: I was passing in a drawing object as input 0 when offset expects an ObjectList. I had been convinced (and thus focused on) that I was not passing input 2 (the offset point) properly instead of realizing that I’d provided the wrong object type. Having (and using!) a dump tool would have exposed my mistake.
Perhaps such an effort is a step toward some future enhanced scripting environment; my intention is to suggest work that ideally benefits your future aims while providing value for users who are trying to write and debug their scripts. Maybe V5 provides some beneficial low hanging fruit, but V6 expands upon it as you see fit; the output of the dump would grow and change as MoI evolves.
--Larry
From: Michael Gibson
Hi Larry, I've updated a couple of scripting things for the next v5 beta to help with that.
The first thing is that all MoI script objects implement a .toString() function that will return the specific object name rather than a generic "MoiObj" name which used to be returned for every object previously.
So for example this:
var obj = moi.geometryDatabase.createObjectList();
var text = obj.toString();
will now generate [object ObjectList] instead of [object MoiObj].
Then the other thing is that property enumeration using the "for...in" syntax will now work on MoI script objects which wasn't implemented previously. Methods will also show up in the enumeration as properties that have a value of '[object Function]'.
So that should enable making a dump function like you're asking about, something like:
code:
function dump( obj )
{
var text = obj.toString();
for ( propname in obj )
text += '\n' + propname + '=' + obj[propname].toString();
return text;
}
- Michael
From: Larry Fahnoe (FAHNOE)
> Hi Larry, I've updated a couple of scripting things for the next v5 beta to help with that.
Wow, thanks Santa!! :-)
> will now generate [object ObjectList] instead of [object MoiObj]
That will be quite nice as it is a bit frustrating to see [object MoiObj] when what I really wanted to see was *which* MoI object it was.
> Then the other thing is that property enumeration using the "for...in" syntax will now work on MoI script
> objects which wasn't implemented previously. Methods will also show up in the enumeration as
> properties that have a value of '[object Function]'.
I think this along with your example dump() will go a long way towards helping script developers have some better insight into the objects
being used. Maybe someday the methods could be fleshed out with their parameters which then makes them somewhat self-documenting.
I'd vote to see dump() show up as dump.js in MoI so that other scripts could simply #include and use it, along with mentions in the release
notes or command reference of course. :-)
Many thanks for such a quick solution!!
--Larry
From: pressure (PEER)
Thanks Michael and Larry! Sounds like some handy new functionality.
Show messages:
1-11
…
372-391
392-411
412-431
432-451
452-471
472-491
492-511
…
632-639