45template <
typename ValueType>
57 Line (ValueType startX, ValueType startY, ValueType endX, ValueType endY)
noexcept
58 :
start (startX, startY),
end (endX, endY)
94 void setStart (ValueType newStartX, ValueType newStartY)
noexcept {
start.setXY (newStartX, newStartY); }
97 void setEnd (ValueType newEndX, ValueType newEndY)
noexcept {
end.setXY (newEndX, newEndY); }
111 start.applyTransform (transform);
112 end.applyTransform (transform);
142 return { startPoint, startPoint.getPointOnCircumference (
length, angle) };
154 bool operator== (
Line other)
const noexcept {
return start == other.start &&
end == other.end; }
157 bool operator!= (
Line other)
const noexcept {
return start != other.start ||
end != other.end; }
224 ValueType perpendicularDistance)
const noexcept
232 return {
start.x +
static_cast<ValueType
> ((delta.x * distanceFromStart - delta.y * perpendicularDistance) /
length),
233 start.y +
static_cast<ValueType
> ((delta.y * distanceFromStart + delta.x * perpendicularDistance) /
length) };
266 auto length = delta.x * delta.x + delta.y * delta.y;
270 auto prop = ((targetPoint.x -
start.x) * delta.x
271 + (targetPoint.y -
start.y) * delta.y) / (
double)
length;
273 if (prop >= 0 && prop <= 1.0)
275 pointOnLine =
start + delta * prop;
276 return targetPoint.getDistanceFrom (pointOnLine);
280 auto fromStart = targetPoint.getDistanceFrom (
start);
281 auto fromEnd = targetPoint.getDistanceFrom (
end);
283 if (fromStart < fromEnd)
304 auto length = delta.x * delta.x + delta.y * delta.y;
307 :
jlimit (ValueType(),
static_cast<ValueType
> (1),
308 static_cast<ValueType
> ((((point.x -
start.x) * delta.x
392 auto divisor = d1.x * d2.y - d2.x * d1.y;
396 if (! (d1.isOrigin() || d2.isOrigin()))
398 if (d1.y == 0 && d2.y != 0)
400 auto along = (p1.y - p3.y) / d2.y;
401 intersection = p1.withX (p3.x + along * d2.x);
405 if (d2.y == 0 && d1.y != 0)
407 auto along = (p3.y - p1.y) / d1.y;
408 intersection = p3.withX (p1.x + along * d1.x);
412 if (d1.x == 0 && d2.x != 0)
414 auto along = (p1.x - p3.x) / d2.x;
415 intersection = p1.withY (p3.y + along * d2.y);
419 if (d2.x == 0 && d1.x != 0)
421 auto along = (p3.x - p1.x) / d1.x;
422 intersection = p3.withY (p1.y + along * d1.y);
427 intersection = (p2 + p3) /
static_cast<ValueType
> (2);
431 auto along1 = ((p1.y - p3.y) * d2.x - (p1.x - p3.x) * d2.y) / divisor;
432 intersection = p1 + d1 * along1;
437 auto along2 = ((p1.y - p3.y) * d1.x - (p1.x - p3.x) * d1.y) / divisor;
#define noexcept
Definition DistrhoDefines.h:72
Line(Point< ValueType > startPoint, Point< ValueType > endPoint) noexcept
Definition juce_Line.h:63
Point< ValueType > start
Definition juce_Line.h:376
Line reversed() const noexcept
Definition juce_Line.h:106
static Line fromStartAndAngle(Point< ValueType > startPoint, ValueType length, ValueType angle) noexcept
Definition juce_Line.h:140
bool isVertical() const noexcept
Definition juce_Line.h:123
Line withLengthenedEnd(ValueType distanceToLengthenBy) const noexcept
Definition juce_Line.h:358
void setStart(ValueType newStartX, ValueType newStartY) noexcept
Definition juce_Line.h:94
Point< ValueType >::FloatType getAngle() const noexcept
Definition juce_Line.h:133
void setStart(const Point< ValueType > newStart) noexcept
Definition juce_Line.h:100
Point< ValueType > getIntersection(Line line) const noexcept
Definition juce_Line.h:165
ValueType getStartY() const noexcept
Definition juce_Line.h:79
Point< ValueType > getPointAlongLineProportionally(typename Point< ValueType >::FloatType proportionOfLength) const noexcept
Definition juce_Line.h:246
Point< ValueType > getPointAlongLine(ValueType distanceFromStart) const noexcept
Definition juce_Line.h:204
Line withLengthenedStart(ValueType distanceToLengthenBy) const noexcept
Definition juce_Line.h:337
Line(ValueType startX, ValueType startY, ValueType endX, ValueType endY) noexcept
Definition juce_Line.h:57
ValueType getLengthSquared() const noexcept
Definition juce_Line.h:120
bool isPointAbove(Point< ValueType > point) const noexcept
Definition juce_Line.h:326
Line withShortenedStart(ValueType distanceToShortenBy) const noexcept
Definition juce_Line.h:348
void setEnd(const Point< ValueType > newEnd) noexcept
Definition juce_Line.h:103
bool intersects(Line other) const noexcept
Definition juce_Line.h:190
ValueType getLength() const noexcept
Definition juce_Line.h:117
ValueType findNearestProportionalPositionTo(Point< ValueType > point) const noexcept
Definition juce_Line.h:301
Line()=default
Definition Geometry.cpp:361
Line< float > toFloat() const noexcept
Definition juce_Line.h:147
static bool isZeroToOne(ValueType v) noexcept
Definition juce_Line.h:378
Point< ValueType > findNearestPointTo(Point< ValueType > point) const noexcept
Definition juce_Line.h:315
Point< ValueType > end
Definition juce_Line.h:376
ValueType getDistanceFromPoint(Point< ValueType > targetPoint, Point< ValueType > &pointOnLine) const noexcept
Definition juce_Line.h:262
void setEnd(ValueType newEndX, ValueType newEndY) noexcept
Definition juce_Line.h:97
Line(const Line &)=default
ValueType getEndY() const noexcept
Definition juce_Line.h:85
bool isHorizontal() const noexcept
Definition juce_Line.h:126
Point< ValueType > getEnd() const noexcept
Definition juce_Line.h:91
ValueType getStartX() const noexcept
Definition juce_Line.h:76
Line< double > toDouble() const noexcept
Definition juce_Line.h:150
ValueType getEndX() const noexcept
Definition juce_Line.h:82
void applyTransform(const AffineTransform &transform) noexcept
Definition juce_Line.h:109
Line withShortenedEnd(ValueType distanceToShortenBy) const noexcept
Definition juce_Line.h:368
Point< ValueType > getPointAlongLine(ValueType distanceFromStart, ValueType perpendicularDistance) const noexcept
Definition juce_Line.h:223
bool intersects(Line line, Point< ValueType > &intersection) const noexcept
Definition juce_Line.h:184
Point< ValueType > getStart() const noexcept
Definition juce_Line.h:88
static bool findIntersection(const Point< ValueType > p1, const Point< ValueType > p2, const Point< ValueType > p3, const Point< ValueType > p4, Point< ValueType > &intersection) noexcept
Definition juce_Line.h:380
Definition juce_Point.h:42
typename TypeHelpers::SmallestFloatType< ValueType >::type FloatType
Definition juce_Point.h:153
unsigned v[N_MAX]
Definition inflate.c:1584
virtual ASIOError start()=0
Definition carla_juce.cpp:31
constexpr Type jmin(Type a, Type b)
Definition juce_MathsFunctions.h:106
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Definition juce_MathsFunctions.h:262
Type juce_hypot(Type a, Type b) noexcept
Definition juce_MathsFunctions.h:352
@ ignored
Definition juce_AccessibilityRole.h:67
png_uint_32 length
Definition png.c:2247
uch * p
Definition crypt.c:594
#define const
Definition zconf.h:137