Need help to write some documentation about U V surfaces.

A place to share learning material: written tutorials, videos, etc.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Need help to write some documentation about U V surfaces.

Post by onekk »

Hello, I'm trying to extend my scripting guide. (that is freely available under a CC license).

I want to write something about UV surfaces, and mapping.

I have some code, but not a decent technical overview about the graphics concepts and matemathics beyond the UV surfaces.

I have done some discussion on forum about this matters, so I have some code, but I could not find the place where someone probably
chrisb wrote:

Chris_G wrote:


has explained me some basics.

Anyone could be so kind to point me on some documentation or similar things.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Need help to write some documentation about U V surfaces.

Post by onekk »

OK I have found this:

https://forum.freecadweb.org/viewtopic. ... 32#p566332

Where I've posted the images, but sadly there are only pratical infos.

Anyone has some more technical infos to make a correct explanation.

As said all this is aimed to my Free scripting guide, so I'm not making money on it.


Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
chrisb
Veteran
Posts: 53930
Joined: Tue Mar 17, 2015 9:14 am

Re: Need help to write some documentation about U V surfaces.

Post by chrisb »

I'm afraid that I can be of no big help. My scripting knowledge covers only very basic things.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
edwilliams16
Veteran
Posts: 3108
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: Need help to write some documentation about U V surfaces.

Post by edwilliams16 »

I have no problem with the math - but all I know about FreeCAD is from my limited explorations. As I understand it, FreeCAD's primary representation of geometry is BREP - boundary representation. (Meshes being an obvious exception.)
Points are just 3D vectors.
Edges are parametric curves bounded by two endpoints (coincident for closed curves).
Faces are parametric surfaces bounded by Wires - a closed sequence of edges.
Solids are bounded by a closed set of Faces.

What is a parametric curve? Imagine a small insect crawling along the curve, starting at one end and proceeding smoothly to the other (smoothly means no stops and starts, no backing up, no sudden jerks of acceleration). Call the time t. For each time t between t_start and t_end the creature has a specific location (x(t), y(t), z(t)) on our curve. Mathematically we express this as

Code: Select all

x = x(t)
y = y(t)
z = z(t) 
telling us the location of the insect as a function of time. This is a parametric representation of the curve. It is not unique. In fact there are an infinite number of possible representations, depending on how fast the insect crawls and how much its speed varies.
The representations that are actually used are ones that have a convenient algebraic form that can be readily manipulated.

Consider a line along the x-axis from x = 0 to x = x_0. The simplest parameterization is

Code: Select all

x = t # 0 <= t <= x_0
Our insect travels at unit speed along the line segment, so that the t parameter is synonymous with distance along the curve. This is the one used in FreeCAD for line segments.
Distance parameterization, although very convenient, is not always available, as even some relatively simple curves, such as ellipses, have no formula for arc-length.

Code: Select all

x = a * cos(t)
y = b * sin(t) # 0<= t <= 2 pi
in fact, is the parameterization used for an ellipse.

Another way of thinking about parameterization - which generalizes nicely to surfaces is to imagine we have an elastic string with distance markings along it. If we lay the unstretched string along our curve, the location of our markings (t=0, t=1 ...) in 3D space is the distance parameterization of our curve. Stretching and compressing our string along the curve provides all the other possible parameterizations.

So moving on to surfaces, imagine now graph paper printed on an elastic sheet. Wrap this sheet onto our surface. Call the coordinates printed on our graph paper u and v. Each coordinate pair maps to a point on our surface. This relation is expressed mathematically as

Code: Select all

x = x(u, v)
y = y(u, v)
z = z(u, v)
As in the curve case, the functions here have to be suitably smooth. Our stretched elastic graph paper cannot have folds or tears or other kinds of discontinuities. If our surface is closed, we have to sew edges of our graph-paper along seams.
Unfortunately, there is no equivalent to the natural distance parameterizations of curves, for surfaces, because in general you cannot lay a flat sheet onto a curved surface without deforming it in some way. The exceptions to these are called developable surfaces, like the surface of a cone. The well known example of this is you can't make a map of the earth without it being deformed in some way. There are large numbers of map projections in use, each of which correspond to a particular parameterization of the sphere (or oblate spheroid).

You can look at how FreeCAD parameterized any given face surface using the Curves workbench IsoCurve tool. It draws lines of constant u and v on the surface. These are the coordinate lines of our stretched graph paper.
Screen Shot 2022-06-17 at 8.46.47 AM.png
Screen Shot 2022-06-17 at 8.46.47 AM.png (32.89 KiB) Viewed 2069 times
Attachments
isocurves.FCStd
(34.9 KiB) Downloaded 32 times
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Need help to write some documentation about U V surfaces.

Post by onekk »

chrisb wrote: Fri Jun 17, 2022 11:48 am I'm afraid that I can be of no big help. My scripting knowledge covers only very basic things.
basic?

I think that your definition of "basic" is slightly underestimated.

:lol:

Thanks for answering.

Could I abuse of your kindness, when I get to make some explanation to ask if there will be some "very big errors"?

TIA and Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Need help to write some documentation about U V surfaces.

Post by onekk »

edwilliams16 wrote: Fri Jun 17, 2022 6:58 pm ...
Thanks, this needs some time to digest.

I have some problems to explain a couple of things:

I could follow the example of graph paper folded on a cylinder curved edges, as it is straight, a part from the periodicity, to make as example a number of turns.

I have some code as we have discussed it a post about "thread making":

https://forum.freecadweb.org/viewtopic.php?f=22&t=65875

But now I need to make some "simple" explanations using something similar to:

tutorial_image012.png
tutorial_image012.png (7.81 KiB) Viewed 1995 times
tutorial_image013.png
tutorial_image013.png (4.29 KiB) Viewed 1995 times
tutorial_image014.png
tutorial_image014.png (4.97 KiB) Viewed 1995 times

That are taken from OCCT makeBottle example:


I could catch the 2*PI length of the surface as this is the circumference of the base circle, and the "number of turns" that will mean to multiply the (2 * PI) factor by number of turns so if I have to make a "3 turns" on the cylinder I have to define a line that will go from:

Code: Select all

 (0,0) to (3 * (2 *PI), Height)
being Height the V dimension that represent the Height of the cylinder.


I have some problems with:
- Cone
- Sphere, I know that here there are some problems of projection, (I have read something about geographical projection)
- Torus, could resemble a Cylinder simply bended, but I dont't catch actually (without making some test the U.V orientation of the Torus)

As when explaining things, some visualization is needed, I could easily re-make images using Tikz in Latex, but obviously I have to give some info not trivial and correct.

I know that is my fault not having studied when young. (at 54 it is not so easy to learn new "complicated" things.) :oops:

But I know also that this could be an hassle, but maybe with some helps something could be made also in a Wiki Page (if Wiki pages will be an option in the near future, as some discussion around seem to indicate).

Many thanks again for your help.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
chrisb
Veteran
Posts: 53930
Joined: Tue Mar 17, 2015 9:14 am

Re: Need help to write some documentation about U V surfaces.

Post by chrisb »

onekk wrote: Sun Jun 19, 2022 10:30 am Could I abuse of your kindness, when I get to make some explanation to ask if there will be some "very big errors"?
I would be happy to have a layman's view on it.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Need help to write some documentation about U V surfaces.

Post by onekk »

chrisb wrote: Wed Jun 22, 2022 8:20 pm I would be happy to have a layman's view on it.
May send you a pdf on PM prior to "publish" ?
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
chrisb
Veteran
Posts: 53930
Joined: Tue Mar 17, 2015 9:14 am

Re: Need help to write some documentation about U V surfaces.

Post by chrisb »

onekk wrote: Thu Jun 23, 2022 12:07 pm May send you a pdf on PM prior to "publish" ?
Yes, of course, but during the next days I may be short of time.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Need help to write some documentation about U V surfaces.

Post by onekk »

chrisb wrote: Fri Jun 24, 2022 11:07 pm
onekk wrote: Thu Jun 23, 2022 12:07 pm May send you a pdf on PM prior to "publish" ?
Yes, of course, but during the next days I may be short of time.
Thanks, it is not a short term goal, probably it will take some time due to family jobs and other things to do.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
Post Reply