<html>
 <head>
  <meta name="viewport" content="width=device-width">
  <meta http-equiv="Content-Type" content="text/vnd.ui.insecure+html;charset=utf-8">
 </head>
 <body style="overflow-wrap:break-word; word-break: break-word;"><div class="mail_android_message" style="line-height: 1; padding: 0.5em">Good point. I can do plain doubles as well of course if that makes it more flexible. <br/><br/>Regarding the length of the perpendicular:<br/>I think the most common use case is to just create any perpendicular with the least computation power. For somebody requiring a specific length I could add an optional "segment length" argument for controlling the<br/>length of the perpendicular line. <br/>What do you think of using a length argument of 0 for a normalized length? (No idea if somebody would need that)<br/><br/>Viele Grüße, Tobias </div><div class="mail_android_quote" style="line-height: 1; padding: 0.3em"><html><body>Am 22.10.20, 08:12 schrieb Nyall Dawson <nyall.dawson@gmail.com>:</body></html><blockquote class="gmail_quote" style="margin: 0.8ex 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

  On Thu, 22 Oct 2020 at 06:43, Tobias Schmetzer <tschmetzer@gmx.de> wrote:
  <br> >
  <br> > Dear developer colleagues,
  <br> >
  <br> > I'm new to QGIS development and my cpp and git experience is a long
  <br> > while ago. Yet I want to make the effort to contribute to this project
  <br> > in return for using it for months.
  <br> >
  <br> > During my python scripting I was missing a function that I created
  <br> > for myself in python which I would need to split a polyline using
  <br> > QgsGeometry.splitGeometry().
  <br> >
  <br> > The function I want to contribute will create a perpendicular segment to
  <br> > a given segment with it's center at a given point (the already available
  <br> > function QgsGeometryUtils.perpendicularSegment doesn't fullfill that need)
  <br> >
  <br> > I would suggest to add to the cpp code of QgsGeometryUtils. A good old
  <br> > friend of mine and cpp expert will do the first code review once it's
  <br> > finished before I do the PR.
  <br> >
  <br> > I am already working on that function and its test. The header looks
  <br> > like this:
  <br> >
  <br> > /**
  <br> > * \brief Create a perpendicular line segment to a given segment
  <br> > * [segmentPoint1, segmentPoint2] with its center at centerPoint
  <br> > * May be used to split geometries
  <br> > * \param centerPoint Point where the center of the perpendicular should
  <br> > * be located
  <br> > * \param segmentPoint1 The segment's start point
  <br> > * \param segmentPoint2 The segment's end point
  <br> > * \returns A line (segment) centered in point p and perpendicular to
  <br> > * segment [segmentPoint1, segmentPoint2]
  <br> > */
  <br> >
  <br> > static QgsLineString perpendicularCenterSegment( const QgsPoint &point,
  <br> > const QgsPoint &segmentPoint1, const QgsPoint &segmentPoint2 ) SIP_HOLDGIL;
  <br> 
  <br> Looks good to me! Some suggestions:
  <br> - instead of accepting QgsPoint values, consider making the arguments
  <br> plain doubles instead. (e.g. double segmentPoint1x, double
  <br> segmentPoint1y, etc). This makes the API more flexible because callers
  <br> who have QgsPointXY or some other input values don't need to do a
  <br> conversion to QgsPoint first.
  <br> - For the same reasons, consider making the method return 4 doubles
  <br> instead of a QgsLineString. E.g. add double& perpendicular1x SIP_OUT,
  <br> double &perpendicular1y SIP_OUT, double& perpendicular2x SIP_OUT,
  <br> double &perpendicular2y SIP_OUT. This again avoids the forced use of
  <br> QgsLineString, and will reap benefits if the function is called many
  <br> times and the caller does not need a QgsLineString object
  <br> - Do you need to add a "segment length" argument for controlling the
  <br> length of the perpendicular line generated?
  <br> 
  <br> Nyall
  <br> 
  <br> 
  <br> >
  <br> > Any comments or did I even miss an already available
  <br> > function for what I am suggesting?
  <br> >
  <br> > Kind regards, Tobias
  <br> > _______________________________________________
  <br> > QGIS-Developer mailing list
  <br> > QGIS-Developer@lists.osgeo.org
  <br> > List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
  <br> > Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
  <br> 
 </blockquote></div></body>
</html>