## How to create parabolas focus point?

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
Posts: 506
Joined: Mon Feb 03, 2020 4:47 pm

### How to create parabolas focus point?

Hi,
For rotation tool, I'm trying to convert a parabola creation by python command (which was working) as follow :

Code: Select all

``````                    const Part::GeomArcOfParabola* arcOfParabola = static_cast<const Part::GeomArcOfParabola*>(geo);
Base::Vector3d rotatedFocusPoint = getRotatedPoint(arcOfParabola->getFocus(), centerPoint, individualAngle * i);
Base::Vector3d rotatedCenterPoint = ;
double arcStartAngle, arcEndAngle;
arcOfParabola->getRange(arcStartAngle, arcEndAngle, /*emulateCCWXY=*/true);
stream << "append(Part.ArcOfParabola(Part.Parabola(App.Vector(" << rotatedFocusPoint.x << "," << rotatedFocusPoint.y << ",0),App.Vector(" << rotatedCenterPoint.x << "," << rotatedCenterPoint.y
<< ",0),App.Vector(0,0,1)),"
<< arcStartAngle << "," << arcEndAngle << "))\n";``````
The stream being used by a docommand later.

And I want to create it like this now :

Code: Select all

``````                    Part::GeomArcOfParabola* arcOfParabola = static_cast<Part::GeomArcOfParabola*>(geo);
arcOfParabola->setCenter(getRotatedPoint(arcOfParabola->getCenter(), centerPoint, individualAngle* i));
//...???
``````
the geometry vector being added later on.
However I cannot rotate the focus point as I have done before by rotating the focus point because there is no setFocus fonction. There is a setfocal but it takes a double.
Just changing the range will not rotate the parabola.
Anyone know?

Digging a little deeper it seems that there should be a 'setXAxis()' function in geometry.cpp/h Or setFocalPoint which is probably the same. With current situation it is not possible to reorient the parabola. (See ArcOfParabolaPyImp.cpp)

Besides, why the focal line is made of construction geometry and not internal geometry?
Posts: 506
Joined: Mon Feb 03, 2020 4:47 pm

### Re: How to create parabolas focus point?

So after reading in more details, the more logical would be to create :
setMajorAxisDir()
getMajorAxisDir()
For parabolas. Along with setFocus and getFocus they define parabolas.
I'm not sure why there's a getFocal() function in the first place as focal point seems to be defined by axis and focus length. Probably a convenience function needed at some point.
But that doesn't change the fact that setMajorAxisDir() getMajorAxisDir() are missing.

Waiting for a confirmation before trying to implement that.
abdullah
Veteran
Posts: 4523
Joined: Sun May 04, 2014 3:16 pm

### Re: How to create parabolas focus point?

paddle wrote: Tue Mar 15, 2022 7:16 am So after reading in more details, the more logical would be to create :
setMajorAxisDir()
getMajorAxisDir()
For parabolas. Along with setFocus and getFocus they define parabolas.
I'm not sure why there's a getFocal() function in the first place as focal point seems to be defined by axis and focus length. Probably a convenience function needed at some point.
But that doesn't change the fact that setMajorAxisDir() getMajorAxisDir() are missing.

Waiting for a confirmation before trying to implement that.
I quite do not remember well... I just provide some pointers.

You have additional tools in GeomArcOfConic. There is a function getAngleXU and setAngleXU, which, if I remember properly was the angle between the X axis and U axis of the parabola. Maybe this works for you?

The arc of parabola is defined by the center (x,y,z), the normal (x,y,z,) at the center, the focal distance (float), the anglexu, and the start and end parameters.

getfocal returns the focal distance. There is also setfocal. There is not any setfocus, getfocus is just convenience function.

Does this help?
Posts: 506
Joined: Mon Feb 03, 2020 4:47 pm

### Re: How to create parabolas focus point?

abdullah wrote: Thu Mar 17, 2022 6:48 pm

I quite do not remember well... I just provide some pointers.

You have additional tools in GeomArcOfConic. There is a function getAngleXU and setAngleXU, which, if I remember properly was the angle between the X axis and U axis of the parabola. Maybe this works for you?

The arc of parabola is defined by the center (x,y,z), the normal (x,y,z,) at the center, the focal distance (float), the anglexu, and the start and end parameters.

getfocal returns the focal distance. There is also setfocal. There is not any setfocus, getfocus is just convenience function.

Does this help?
Yes thanks I think that should be it!
I didn't thought about looking into arcofconic! Because ellipse and hyperbolas have their 'getmajor axis' function, so I guessed it would have been similar.

I'll test tomorrow.

Btw have you seen the videos I published on offset? It's working great. And I used some constraints and construction geo to make a 'offset lengths constraints'
So it makes it kind of dependant on original géométries.
Posts: 506
Joined: Mon Feb 03, 2020 4:47 pm

### Re: How to create parabolas focus point?

I confirm that was it. Parabolas now turn as expected.
Now rotate/circular pattern works perfectly for all geometries including bspline.
Posts: 506
Joined: Mon Feb 03, 2020 4:47 pm

### Re: How to create parabolas focus point?

abdullah wrote: Thu Mar 17, 2022 6:48 pm The arc of parabola is defined by the center (x,y,z), the normal (x,y,z,) at the center, the focal distance (float), the anglexu, and the start and end parameters.
So now I'm also trying to get parabolas to work on Scale tool. It's the last geometry which is not working for these rotate/scale tools.
The code I'm using is :

Code: Select all

``````                Part::GeomArcOfParabola* arcOfParabola = static_cast<Part::GeomArcOfParabola*>(geo);
arcOfParabola->setFocal(arcOfParabola->getFocal() * scaleFactor);
arcOfParabola->setCenter(getScaledPoint(arcOfParabola->getCenter(), referencePoint, scaleFactor));
And it's not working properly. The start and end points are not correct. parabolas.png (46.24 KiB) Viewed 1074 times
I expected that the start/end points were determined by the startAngle and end angle, so that scaling shouldn't need to modify the angles (as it's the case for the other arcs.).
I thought maybe the angles are modified by the setFocal but getRange before setfocal then setRange after doesn't help.
abdullah
Veteran
Posts: 4523
Joined: Sun May 04, 2014 3:16 pm

### Re: How to create parabolas focus point?

paddle wrote: Fri Mar 18, 2022 9:17 am I expected that the start/end points were determined by the startAngle and end angle, so that scaling shouldn't need to modify the angles (as it's the case for the other arcs.).
I thought maybe the angles are modified by the setFocal but getRange before setfocal then setRange after doesn't help.
First, it is not apparent whether you are working with a cloned geometry or not. I am going to assume you are. If you are not you should change that.

When you change the focal, you change the amount the parabola "opens" or "closes". So even with the same trimming parameters it won't go to the same end points (it is also not expected to). The OCC parametrisation of the parabola is:
P(U) = O + U*U/(4.*F)*XDir + U*YDir

However, it should keep the shape (as you expect).

I would suspect the solver is messing with you.

To check this, I would add some debug code to printout to console the values of the parameters after doing those modifications. Then I will compare these values with values obtained from Python after the command is executed (and thus solved). If you are not getting the same values (and I expect you are not), you need to track down where you parameters are being "changed".
edwilliams16
Veteran
Posts: 1368
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

### Re: How to create parabolas focus point?

paddle wrote: Fri Mar 18, 2022 9:17 am
I expected that the start/end points were determined by the startAngle and end angle, so that scaling shouldn't need to modify the angles (as it's the case for the other arcs.).
I thought maybe the angles are modified by the setFocal but getRange before setfocal then setRange after doesn't help.
Ellipses and hyperbolas are parameterized by angles, which don't change with scaling. However, parabolas basic parameterization is

Code: Select all

``````y = u
x = u^2/(4a)``````
if we rescale x -> fx, y-> fy, then

Code: Select all

``````y = f*u
x = f*u^2/(4a)``````
re-parameterizing with v = f*u

Code: Select all

``````y = v
x = v^2/(4af)``````
we get a new parabola with a -> f*a
BUT if the range of u was u_0 to u_1, the range of v is from f*u_0 to f*v_0

So unlike ellipses and parabolas we have to scale the end-point parameters.

Rotations and displacements work the same for all conics.
edwilliams16
Veteran
Posts: 1368
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

### Re: How to create parabolas focus point?

Here's a python version that scales a parabolic arc. I'm ignorant of C++:

Code: Select all

``````#Parabolic arc
# equation y^2 = 4*a*x
#parametric representation
#x = u^2/(4*a)
#y = u
from math import pi, radians, sin, cos

V2 = App.Base.Vector2d

#make test arc
loc = V2(1,1)   #origin of arc
angle = radians(30) #rotated from X-Axis
xrot = V2(cos(angle), sin(angle))
parabola = Part.Geom2d.Parabola2d()
parabola.Focal = 1/4
uStart = 3
uEnd = -6
parabola.Location = loc
parabola.XAxis = xrot  #YAxis internally recomputed
parabolaArc = Part.Geom2d.ArcOfParabola2d(parabola, uStart, uEnd)
Part.show(parabolaArc.toShape())

def scaleParabolaArc(parabolaArc, scaleFactor, center2d):
''' scaleParabolaArc(parabolaArc, scaleFactor, center2d) return arc scaled by scaleFactor about the center2d fixed point'''
scaledParabolaArc  = Part.Geom2d.ArcOfParabola2d(parabolaArc.Parabola, parabolaArc.FirstParameter * scaleFactor, parabolaArc.LastParameter * scaleFactor)
scaledParabolaArc.Focal = parabolaArc.Focal *scaleFactor
scaledParabolaArc.Location = center2d + (parabolaArc.Location - center2d) * scaleFactor
return scaledParabolaArc

#create scaled arc
factor = 0.5
center2d = V2(2,1) #fixed point of scaling
scaled = scaleParabolaArc(parabolaArc, factor, center2d)
Part.show(scaled.toShape())

``````