buildingSMART / IFC4.x-IF

IFC4.x Implementers Forum
28 stars 33 forks source link

Proper representation entity for IfcAlignmentCant segment of type LINEARTRANSITION #145

Open civilx64 opened 4 months ago

civilx64 commented 4 months ago

Example data appears to incorrectly implement linear transitions of alignment cant layouts

Concept Templates 4.2.2.2 are very useful for understanding which ParentCurve entity type should be used for various business logic segment types. However, this documentation only addresses PredefinedType values for IfcAlignmentHorizontal.

One example is the entity type to be used as the IfcCurveSegment.ParentCurve that serves as representation of a cant business logic segment of type LINEARTRANSITION. The current documentation suggests that IfcLine should always be used to represent a cant LINEARTRANSITION. Specifically, the base formula in the documentation for IfcAlignemtCantSegmentTypeEnum indicates a linear variation in the amount of cant over the length of the segment:

image

This contradicts at least two examples currently in the wild:

  1. Sample model linear-placement-of-signal.ifc where IfcClothoid is used as parent curve of segment # 2605 which is the representation of business logic segment # 2399 having DesignParameters # 2404 with PredefinedType = LINEARTRANSITION
  2. Reference code from the IFC Rail room, specifically the Enrich4x3 utility that can be used to generate the geometry repesentation of an alignment in a model that contains business logic only

The confusion in the two examples listed above likely stems from the reference to linear transition of cant being the "natural" formula for horizontal clothoids. This sentence in the documentation is correct - cant is varied in a linear manner for the same length and over the same beginning and end of a clothoid transition segment in the horizontal alignment. This allows for the centripetal acceleration experienced by the vehicle body as it traverses the horizontal alignment to be counter-acted in a synchronized manner by the introduction of cant.

If the design intent truly is to use a non-linear transition between two cant values, other PredefinedType values such as BLOSSCURVE or VIENNESEBEND should be utilized in the cant business logic segment.

Solution(s)

The two examples listed above should be revised from IfcClothoid to IfcLine to align with the schema.

Require schema changes?

Require documentation changes?

Expansion of the Concept Templates might be helpful to make this explicitly clear, but the current documentation clearly indicates that LINEARTRANSITION of cant should be represented by IfcLine.

Rule required Need for a formal rule? Describe it

This relates to rule ALA003 which is currently under development as part of the IFC Validation Service. ALA003 will report a validation error when IfcClothoid is utilized as representation of a cant LINEARTRANSITION.

Additional context An SVG graph of the alignment data in linear-placement-of-signal.ifc

linear-placement-of-signal

evandroAlfieri commented 4 months ago

@peterrdf have you seen those two files? Can you confirm they are incorrect? Any input from you is very appreciated

apinzenoehler commented 4 months ago

Hmmm .....

That seems to be a rather complex misunderstanding.

The description in the schema for "IfcAlignmentCantSegmentTypeEnum" might lead the fast readers to wrong conclusions.

To understand alignment in the rail business one needs to understand the horizontal layout, the vertical layout and the cant layout at the same time.

In the Ifc 4.3 context this means that one must read https://standards.buildingsmart.org/IFC/RELEASE/IFC4_3/HTML/lexical/IfcAlignmentHorizontalSegmentTypeEnum.htm , https://standards.buildingsmart.org/IFC/RELEASE/IFC4_3/HTML/lexical/IfcAlignmentVerticalSegmentTypeEnum.htm and https://standards.buildingsmart.org/IFC/RELEASE/IFC4_3/HTML/lexical/IfcAlignmentCantSegmentTypeEnum.htm together.

And it is very helpful to keep in mind that each layout is dealing with a separate distinct parameter.

In the horizontal layout the relevant parameter is the curvature, in the vertical layout it is the gradient and in the cant layout it is the bank-angle or the much better to measure cant-value (occasionally also known as superelevation).

So transition bends like IfcAlignmentHorizontalSegmentTypeEnum.CLOTHOID describe trackgeometry segments which deal with the smoothing of direction changes. Its purpose is to give the curvature some time/space to adapt to the curves in the track and to reduce the jerk exerted to running trains.

For CLOTHOID the curvature change is linear in reference to the relevant segment extension. It usually does not matter much if one uses the segment length or the time a vehicle needs to pass the segment to express this mathematically.

IfcAlignmentCantSegmentTypeEnum deals with the compensation of lateral acceleration experienced by a vehicle in a curve. For changes of this parameter smoothing is applied too. Similar to the horizontal layout linear smoothing is the most common.

IfcAlignmentCantSegmentTypeEnum.LINEARTRANSITION defines the rate of change of the parameter cant (angle or value) to be constant in reference to the length of the segment. With the horizontal CLOTHOID the LINEARTRANSITION segment shares the same mathematical function, although there are two different physical concepts behind it.

Now comes the complicated/confusing part: because of the kinematic objectives horizontal CLOTHOID elements and cant LINEARTRANSITION elements typically share the same extension (start station to end station). Therefore very often the term clothoid is used for both concepts.

In the early stages of Ifc 4.3 development there was a cant enumeration CLOTHOID. This was replaced by LINEARTRANSITION to provide a clear indication of the separate concepts. The sentence "Linear cant variation. This is the 'natural' formula for horizontal clothoids." in IfcAlignmentCantSegmentTypeEnum is a leftover of this editing phase. It was meant to make it easier for the average rail engineer to read the text. I know this because I wrote the first draft.

What does this mean for geometry representations? Here I have only a hearsay contribution to make. According to my memory the ParentCurve IfcClothoid for cant LINEARTRANSITION was chosen simply to avoid introducing new entities. Please take this with a grain of salt, maybe @peterrdf or Sergej can confirm it or give a better explanation.

civilx64 commented 4 months ago

In the Ifc 4.3 context this means that one must read https://standards.buildingsmart.org/IFC/RELEASE/IFC4_3/HTML/lexical/IfcAlignmentHorizontalSegmentTypeEnum.htm , https://standards.buildingsmart.org/IFC/RELEASE/IFC4_3/HTML/lexical/IfcAlignmentVerticalSegmentTypeEnum.htm and https://standards.buildingsmart.org/IFC/RELEASE/IFC4_3/HTML/lexical/IfcAlignmentCantSegmentTypeEnum.htm together.

I did review all three together.

Now comes the complicated/confusing part: because of the kinematic objectives horizontal CLOTHOID elements and cant LINEARTRANSITION elements typically share the same extension (start station to end station).

Yes, I understand this. I stated the same in my original comment, although maybe could have worded it differently to be more clear.

Therefore very often the term clothoid is used for both concepts.

Ok. I was not aware of that. So the similarity is that in the horizontal layout, the clothoid provides a linear adjustment of curvature over the same station range as the linear adjustment of cant.

The sentence "Linear cant variation. This is the 'natural' formula for horizontal clothoids." in IfcAlignmentCantSegmentTypeEnum is a leftover of this editing phase. It was meant to make it easier for the average rail engineer to read the text. I know this because I wrote the first draft.

I hope my reference to this section did not come across as criticism. That certainly was not my intent.

According to my memory the ParentCurve IfcClothoid for cant LINEARTRANSITION was chosen simply to avoid introducing new entities. Please take this with a grain of salt, maybe @peterrdf or Sergej can confirm it or give a better explanation.

If I graph a long section of the cant based purely on the business logic information in the signal placement example, I get nothing but linear segments:

IfcAlignmentCant

This corresponds to geometry in the isolated cant parameter space defined by a series of IfcLine entity types, not a repeating pattern of IfcLine, IfcClothoid, IfcLine...

evandroAlfieri commented 3 months ago

@civilx64 will ALA003 close this issue or do you think we need a change in docs too?

civilx64 commented 3 months ago

Yes, ALA003 will close this issue. There's no need to update the 4.2.2.2 concept template as it already indicates IfcLine for linear segments.

I'd recommend including some clarifying text in the Validation Service docs. I developed a table of documentation already as it was helpful when implementing the rule.

civilx64 commented 2 months ago

Deployed in v0.6 of Validation Service via normative rule ALA003.

RickBrice commented 1 month ago

If I graph a long section of the cant based purely on the business logic information in the signal placement example, I get nothing but linear segments:

Yes, but the horizontal linear segments are constant value (slope = 0). Cant and curvature are the derivative of the parent curve function and have the same functional form. The derivative of IfcLine is a constant value (zero or otherwise). The derivative of IfcClothoid is linear. IfcLine cannot represent a linearly increasing cant because its derivative is a constant value.

This corresponds to geometry in the isolated cant parameter space defined by a series of IfcLine entity types, not a repeating pattern of IfcLine, IfcClothoid, IfcLine...

The parent curves for the IfcSegmentReferenceCurve in the linear-placement-of-signal example are alternating IfcLine, IfcClothoid, IfcLine, ... I believe this is correct.

civilx64 commented 1 month ago

Cant and curvature are the derivative of the parent curve function and have the same functional form.

Yes, curvature is the derivative of the 2D (x-y space) parent curve. How is cant the derivative of the parent curve?

The derivative of IfcLine is a constant value (zero or otherwise). The derivative of IfcClothoid is linear.

Agreed.

IfcLine cannot represent a linearly increasing cant because its derivative is a constant value.

I agree with the logic but am still struggling to understand how cant is the derivative.

peterrdf commented 1 month ago

I understand it is confusing, I disagreed with it and did not understand the solution at first also. Now I see it makes sense (given restrictions in the schema) an think it is a good solution even though it is arguably a bit too much getting infrastructure domain knowledge in the geometry domain.

So technically the same IfcCurveSegment instance could be used as a segment for IfcCompositeCurve, IfcGradientCurve and for IfcSegmentedReferenceCurve (note that I would not advise this). In IfcCompositeCurve and IfcGradientCurve this segment (if its ParentCurve is an IfcClothoid) represents a non linear profile (i.e. a simple spiral part), while the same segment represents a linear profile if used by IfcSegmentedReferenceCurve.

Another confusig factor can be that enumeration values (of IfcAlignmentCantSegmentTypeEnum) can be seen as inconsequent while CONSTANTCANT and LINEARTRANSITION represent the actual profile in geometry the other enumeration values slightly more define the actual IfcCurveSegment.ParentCurve definition (still derived from the way the domain looks at these terms).

RickBrice commented 1 month ago

@civilx64, it took me way too long to understand this, and I'm only about 95% confident in my understanding.

I think the relationship between cant and the derivative is easier to see with the polynomial spirals. Consider a Bloss curve with a IfcThirdOrderPolynomialSpiral parent curve.

In the 2D horizontal space, the slope or tangent of the curve taken from 8.9.3.72 is

$$\theta(t) = \frac{A_3}{4|A_3^5|}t^4 +\frac{t^3}{3A_2^3}+\frac{A_1 t^2}{2|A_1^3|}+\frac{t}{A_0}$$

Curvature is the derivative of this function

$$k(t) = \frac{d}{dt}(\theta(t))$$ $$k(t) = \frac{A_3}{|A_3^5|}t^3 +\frac{1}{A_2^3}t^2+\frac{A_1}{|A_1^3|}t+\frac{1}{A_0}$$

Now consider the cant equation for a Bloss transition $$D(s)=D_1+(3-2\frac{s}{L})(\frac{s}{L})^2\Delta D $$

Expand the terms $$D(s)=D_1+3\Delta D(\frac{s}{L})^2-2\Delta D(\frac{s}{L})^3$$

This equation has the same form as the curvature equation. They are both cubic polynomials.

Parameter: $t = \frac{s}{L}$

Constant term: $D_1 = \frac{1}{A_0}$

Linear term: $\frac{A_1}{|A_1^3} = 0$

Quadratic term: $\frac{1}{A_2^3} = 3\Delta D$

Cubic term: $\frac{A_3}{|A_3^5|} = -2\Delta D$

So that's the basic idea as I understand it. The math seems to be a little different in practice. Using the EnrichIFC4x3 program in the Rail repository - thanks @peterrdf this was a huge help, I have reverse engineered the following.

The Bloss curve equation for cant is

$$ D(s) = \frac{A_3L}{|A_3^5|}s^3 + \frac{L}{A_2^3}s^2+\frac{A_1L}{2|A_1^3|}s+\frac{L}{A_0}$$

This has the same functional form as before.

From the business logic

start left cant: $D_{sl}$

start right cant: $D_{sr}$

end left cant: $D_{el}$

end right cant: $D_{er}$

$D1 = \frac{D{sl} + D_{sr}}{2}$

$D2 = \frac{D{el} + D_{er}}{2}$

$\Delta D = D_2 - D_1$

$f = \Delta D$

Constant term: $a_0 = D_1, A_0 = \frac{L}{|a_0|} \frac{a_0}{|a_0|}$

Linear term: $a_1 = 0, A_1 = \frac{L}{\sqrt{|a_1|}} \frac{a_1}{|a_1|} = 0$

Quadratic term: $a_2 = 3f, A_2 = \frac{L}{\sqrt[3]{|a_2|}} \frac{a_2}{|a_2|}$

Cubic term: $a_3 = -2f, A_3 =\frac{L}{\sqrt[4]{|a_3|}} \frac{a_3}{|a_3|}$

Using the GENERATED__CantAlignment_BlossCurve_100.0_1000_300_1_Meter.ifc example.

#64 = IFCALIGNMENTCANTSEGMENT($, $, 0., 100., 0., 0., 0., 1.6E-1, .BLOSSCURVE.);
#127 = IFCTHIRDORDERPOLYNOMIALSPIRAL(#128, -158.113883008419, 160.914897434272, $, $);

$D_1 = \frac{0+0}{2}=0, D_2 = \frac{0+0.16}{2}=0.08, \Delta D = f = 0.08 - 0 = 0.08$

Constant term: $a_0 = 0, A_0 = 0$

Linear term: $A_1 = 0$

Quadratic term: $a_2 = 3f = 3(0.08) = 0.24, A_2 = \frac{100}{\sqrt[3]{|0.24|}}\frac{0.24}{|0.24|}=160.9148974$

Cubic term: $a_3 = -2f = -2(0.08) = -0.16, A_3 = \frac{100}{\sqrt[4]{|-0.16|}}\frac{-0.16}{|-0.16|}=-158.113883$

Evaluate the cant curve at $s=50$

$D(50)=\frac{A_3}{|A_3^5|}Ls^3+\frac{1}{A_2^3}Ls^2=\frac{-158.113883}{|-158.113883^5|}(100)(50^3)+\frac{100}{160.9148974^3}(50)^2=0.04$

I understand this to mean the IfcSegmentedReferenceCurve is 0.04 meter above the IfcGradientCurve at 50 m along the segment. Additionally, the Axis vector (assuming a rail head distance of 1.5 m) is:

image

$R = 1.5$ $2D = 2(0.04) = 0.08$ $\sqrt{0.08^2 + 1.5^2} = 1.50213$ $dx = 0.0$ $dy = \frac{0.08}{1.50213}=0.053257$ $dz = \frac{1.5}{1.50213}=0.99858$

I'm sure my explanation isn't perfectly mathematically correct, but this is what I understand about cant.

civilx64 commented 1 month ago

@peterrdf @RickBrice thanks very much to you both for explaining this. I stepped away from the theory a bit and did some calculations for the sample model and ended up with exactly the results I would have expected for the linear transition in cant. So I agree that the Validation Service should be modified accordingly.

Which leads to the next question: does the Validation Service need additional revisions for other values of the possible cant segment type enumerations? Here is the current logic behind ALA003:

Business Logic Segment PredefinedType Representation Entity
BLOSSCURVE IfcThirdOrderPolynomialSpiral
CONSTANTCANT IfcLine
COSINECURVE IfcCosineSpiral
HELMERTCURVE IfcSecondOrderPolynomialSpiral
LINEARTRANSITION IfcLine to be revised to IfcClothoid
SINECURVE IfcSineSpiral
VIENNESEBEND IfcSeventhOrderPolynomialSpiral
peterrdf commented 1 month ago

looks correct to me, just note that an HELMERTCURVE exists of two segments (both IfcSecondOrderPolynomialSpiral)

RickBrice commented 1 month ago

I’m not certain the linear-placement-of-signal.ifc example is correct. Seems like that is a discussion for a different thread. I’ll post soon so we can discuss.