KiCad PCB EDA Suite
|
Go to the source code of this file.
Functions | |
bool | IsPointOnSegment (const VECTOR2I &aSegStart, const VECTOR2I &aSegEnd, const VECTOR2I &aTestPoint) |
Test if aTestPoint is on line defined by aSegStart and aSegEnd. | |
bool | SegmentIntersectsSegment (const VECTOR2I &a_p1_l1, const VECTOR2I &a_p2_l1, const VECTOR2I &a_p1_l2, const VECTOR2I &a_p2_l2, VECTOR2I *aIntersectionPoint=nullptr) |
Test if two lines intersect. | |
void | RotatePoint (int *pX, int *pY, const EDA_ANGLE &aAngle) |
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0. | |
void | RotatePoint (VECTOR2I &point, const EDA_ANGLE &aAngle) |
Rotate a VECTOR2I in place by aAngle. | |
VECTOR2I | GetRotated (const VECTOR2I &aVector, const EDA_ANGLE &aAngle) |
Return a new VECTOR2I that is the result of rotating aVector by aAngle. | |
void | RotatePoint (int *pX, int *pY, int cx, int cy, const EDA_ANGLE &aAngle) |
Calculate the new point of coord coord pX, pY, for a rotation center cx, cy. | |
void | RotatePoint (VECTOR2I &aPoint, const VECTOR2I &aCentre, const EDA_ANGLE &aAngle) |
Rotate a VECTOR2I in place by aAngle about aCentre. | |
VECTOR2I | GetRotated (const VECTOR2I &aVector, const VECTOR2I &aCentre, const EDA_ANGLE &aAngle) |
Return a new VECTOR2I that is the result of rotating aVector by aAngle. | |
void | RotatePoint (double *pX, double *pY, const EDA_ANGLE &aAngle) |
Calculate the new coord point point for a rotation center 0, 0. | |
void | RotatePoint (VECTOR2D &point, const EDA_ANGLE &aAngle) |
void | RotatePoint (double *pX, double *pY, double cx, double cy, const EDA_ANGLE &aAngle) |
void | RotatePoint (VECTOR2D &point, const VECTOR2D &aCenter, const EDA_ANGLE &aAngle) |
const VECTOR2I | CalcArcCenter (const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd) |
Determine the center of an arc or circle given three points on its circumference. | |
const VECTOR2D | CalcArcCenter (const VECTOR2D &aStart, const VECTOR2D &aMid, const VECTOR2D &aEnd) |
const VECTOR2D | CalcArcCenter (const VECTOR2D &aStart, const VECTOR2D &aEnd, const EDA_ANGLE &aAngle) |
const VECTOR2I | CalcArcMid (const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, bool aMinArcAngle=true) |
Return the middle point of an arc, half-way between aStart and aEnd. | |
bool | TestSegmentHit (const VECTOR2I &aRefPoint, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aDist) |
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd. | |
double | DEG2RAD (double deg) |
double | RAD2DEG (double rad) |
double | RAD2DECIDEG (double rad) |
template<class T > | |
T | NormalizeAnglePos (T Angle) |
Normalize angle to be in the 0.0 . | |
template<class T > | |
void | NORMALIZE_ANGLE_POS (T &Angle) |
template<class T > | |
T | NormalizeAngle180 (T Angle) |
Normalize angle to be in the -180.0 . | |
bool | InterceptsPositiveX (double aStartAngle, double aEndAngle) |
Test if an arc from aStartAngle to aEndAngle crosses the positive X axis (0 degrees). | |
bool | InterceptsNegativeX (double aStartAngle, double aEndAngle) |
Test if an arc from aStartAngle to aEndAngle crosses the negative X axis (180 degrees). | |
const VECTOR2D CalcArcCenter | ( | const VECTOR2D & | aStart, |
const VECTOR2D & | aEnd, | ||
const EDA_ANGLE & | aAngle | ||
) |
Definition at line 333 of file trigo.cpp.
References ANGLE_0, ANGLE_180, ANGLE_360, ANGLE_90, VECTOR2< T >::Resize(), RotatePoint(), and EDA_ANGLE::Sin().
Referenced by CalcArcCenter().
const VECTOR2D CalcArcCenter | ( | const VECTOR2D & | aStart, |
const VECTOR2D & | aMid, | ||
const VECTOR2D & | aEnd | ||
) |
Definition at line 369 of file trigo.cpp.
References std::abs(), CircleCenterFrom3Points(), VECTOR2< T >::EuclideanNorm(), VECTOR2< T >::x, and VECTOR2< T >::y.
const VECTOR2I CalcArcCenter | ( | const VECTOR2I & | aStart, |
const VECTOR2I & | aMid, | ||
const VECTOR2I & | aEnd | ||
) |
Determine the center of an arc or circle given three points on its circumference.
aStart | The starting point of the circle (equivalent to aEnd). |
aMid | The point on the arc, half-way between aStart and aEnd. |
aEnd | The ending point of the circle (equivalent to aStart). |
Definition at line 521 of file trigo.cpp.
References CalcArcCenter(), KiROUND(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by GRAPHICS_IMPORTER_LIB_SYMBOL::AddArc(), GRAPHICS_IMPORTER_SCH::AddArc(), PLOTTER::Arc(), BOOST_AUTO_TEST_CASE(), SHAPE_ARC::ConstructFromStartEndAngle(), KIGFX::SCH_PAINTER::draw(), PCB_ARC::GetPosition(), PCB_ARC::GetRadius(), SCH_IO_KICAD_SEXPR_PARSER::parseSymbolArc(), EDA_SHAPE::SetArcGeometry(), SHAPE_ARC::update_values(), and ARC_GEOM_SYNCER::Validate().
const VECTOR2I CalcArcMid | ( | const VECTOR2I & | aStart, |
const VECTOR2I & | aEnd, | ||
const VECTOR2I & | aCenter, | ||
bool | aMinArcAngle = true |
||
) |
Return the middle point of an arc, half-way between aStart and aEnd.
There are two possible solutions which can be found by toggling aMinArcAngle. The behavior is undefined for semicircles (i.e. 180 degree arcs).
aStart | The starting point of the arc (for calculating the radius). |
aEnd | The end point of the arc (for determining the arc angle). |
aCenter | The center point of the arc. |
aMinArcAngle | If true, returns the point that results in the smallest arc angle. |
Definition at line 209 of file trigo.cpp.
References ANGLE_180, and RotatePoint().
Referenced by CIRCLE::ConstructFromTanTanPt(), EDIT_TOOL::DragArcTrack(), and PCB_IO_EAGLE::loadSignals().
|
inline |
Definition at line 166 of file trigo.h.
Referenced by DXF_IMPORT_PLUGIN::addInsert(), ConvertArcCenter(), PNS::MEANDER_SHAPE::cornerRadius(), EXPORTER_PCB_VRML::ExportVrmlFootprint(), PCB_TUNING_PATTERN::getOutline(), HelperShapeLineChainFromAltiumVertices(), PCBNEW_JOBS_HANDLER::JobExportRender(), CADSTAR_PCB_ARCHIVE_LOADER::loadDimensions(), PCB_IO_EAGLE::loadPolygon(), PNS::MEANDER_SHAPE::makeMiterShape(), PNS::MEANDER_SHAPE::MinAmplitude(), PCB_IO_EAGLE::packagePolygon(), PCB_IO_EASYEDAPRO_PARSER::ParseBoard(), PCB_IO_EASYEDAPRO_PARSER::ParseContour(), PCB_IO_EASYEDAPRO_PARSER::ParsePoly(), STEP_PCB_MODEL::performMeshing(), DRC_TEST_PROVIDER_SLIVER_CHECKER::Run(), and DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testShapeLineChain().
Return a new VECTOR2I that is the result of rotating aVector by aAngle.
Definition at line 77 of file trigo.h.
References RotatePoint(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by BOOST_AUTO_TEST_CASE(), ComputeDogbone(), KIGEOM::ConvertToChain(), DIM_ALIGNED_TEXT_UPDATER::getDimensionNewTextPosition(), LINE_GEOM_SYNCER::OnPolarChange(), OUTSET_ROUTINE::ProcessItem(), and EDA_TEXT::TextHitTest().
|
inline |
Return a new VECTOR2I that is the result of rotating aVector by aAngle.
Definition at line 100 of file trigo.h.
References RotatePoint(), VECTOR2< T >::x, and VECTOR2< T >::y.
|
inline |
Test if an arc from aStartAngle to aEndAngle crosses the negative X axis (180 degrees).
Testing is performed in the quadrant 1 to quadrant 4 direction (counter-clockwise).
aStartAngle | The arc start angle in degrees. |
aEndAngle | The arc end angle in degrees. |
Definition at line 233 of file trigo.h.
Referenced by BOOST_AUTO_TEST_CASE().
|
inline |
Test if an arc from aStartAngle to aEndAngle crosses the positive X axis (0 degrees).
Testing is performed in the quadrant 1 to quadrant 4 direction (counter-clockwise).
aStartAngle | The arc start angle in degrees. |
aEndAngle | The arc end angle in degrees. |
Definition at line 215 of file trigo.h.
Referenced by BOOST_AUTO_TEST_CASE().
bool IsPointOnSegment | ( | const VECTOR2I & | aSegStart, |
const VECTOR2I & | aSegEnd, | ||
const VECTOR2I & | aTestPoint | ||
) |
Test if aTestPoint is on line defined by aSegStart and aSegEnd.
This function is faster than TestSegmentHit() because aTestPoint should be exactly on the line. This only works for horizontal, vertical, and 45 degree line segments.
aSegStart | The first point of the line segment. |
aSegEnd | The second point of the line segment. |
aTestPoint | The point to test. |
Definition at line 89 of file trigo.cpp.
References VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by SCH_LINE_WIRE_BUS_TOOL::finishSegments(), SCH_SCREEN::GetBusesAndWires(), SCH_SCREEN::GetNeededJunctions(), SCH_LINE_WIRE_BUS_TOOL::TrimOverLappingWires(), SCH_EDIT_FRAME::TrimWire(), SCH_BUS_WIRE_ENTRY::UpdateDanglingState(), and SCH_BUS_BUS_ENTRY::UpdateDanglingState().
|
inline |
Definition at line 187 of file trigo.h.
References NormalizeAnglePos().
Referenced by SCH_IO_KICAD_LEGACY_LIB_CACHE::loadArc(), and MapAnglesV6().
|
inline |
Normalize angle to be in the -180.0 .
. 180.0 range.
Definition at line 196 of file trigo.h.
Referenced by DIALOG_COPPER_ZONE::AcceptOptions(), and PANEL_ZONE_PROPERTIES::AcceptOptions().
|
inline |
Normalize angle to be in the 0.0 .
. 360.0 range: angle is in 1/10 degrees.
Definition at line 178 of file trigo.h.
Referenced by NORMALIZE_ANGLE_POS().
|
inline |
Definition at line 170 of file trigo.h.
Referenced by MapAnglesV6().
|
inline |
Definition at line 167 of file trigo.h.
Referenced by GBR_TO_PCB_EXPORTER::export_non_copper_item(), and PCB_BASE_FRAME::UpdateStatusBar().
void RotatePoint | ( | double * | pX, |
double * | pY, | ||
const EDA_ANGLE & | aAngle | ||
) |
Calculate the new coord point point for a rotation center 0, 0.
Definition at line 295 of file trigo.cpp.
References ANGLE_0, ANGLE_180, ANGLE_270, ANGLE_90, EDA_ANGLE::Cos(), EDA_ANGLE::Normalize(), EDA_ANGLE::Sin(), VECTOR2< T >::x, and VECTOR2< T >::y.
void RotatePoint | ( | double * | pX, |
double * | pY, | ||
double | cx, | ||
double | cy, | ||
const EDA_ANGLE & | aAngle | ||
) |
Definition at line 281 of file trigo.cpp.
References RotatePoint().
void RotatePoint | ( | int * | pX, |
int * | pY, | ||
const EDA_ANGLE & | aAngle | ||
) |
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
Definition at line 229 of file trigo.cpp.
References ANGLE_0, ANGLE_180, ANGLE_270, ANGLE_90, EDA_ANGLE::Cos(), KiROUND(), EDA_ANGLE::Normalize(), EDA_ANGLE::Sin(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by DXF_IMPORT_PLUGIN::addArc(), GRAPHICS_IMPORTER_LIB_SYMBOL::AddArc(), GRAPHICS_IMPORTER_SCH::AddArc(), GRAPHICS_IMPORTER_PCBNEW::AddArc(), PCAD2KICAD::PCAD_FOOTPRINT::AddToBoard(), PCAD2KICAD::PCAD_PAD::AddToFootprint(), EC_CIRCLE::Apply(), CADSTAR_SCH_ARCHIVE_LOADER::applyTransform(), SVG_PLOTTER::Arc(), BOOST_AUTO_TEST_CASE(), PCB_TEXT::buildBoundingHull(), BuildConvexHull(), BuildCornersList_S_Shape(), PAD::buildEffectiveShape(), PAD::BuildEffectiveShapes(), DIRECTION_45::BuildInitialTrace(), ZONE_FILLER::buildThermalSpokes(), CalcArcCenter(), CalcArcMid(), PNS::OPTIMIZER::circleBreakouts(), SHAPE_ARC::Collide(), commonParallelProjection(), PCB_GRID_HELPER::computeAnchors(), computeCenter(), PSLIKE_PLOTTER::computeTextParameters(), ConnectBoardShapes(), SHAPE_ARC::ConstructFromStartEndAngle(), SHAPE_ARC::ConstructFromStartEndCenter(), AM_PRIMITIVE::ConvertBasicShapeToPolygon(), ALTIUM_PCB::ConvertComponentBody6ToFootprintItem(), convertOblong2Segment(), AM_PRIMITIVE::ConvertShapeToPolygon(), D_CODE::ConvertShapeToPolygon(), CornerListToPolygon(), PCAD2KICAD::CorrectTextPosition(), BOARD_ADAPTER::createArcSegments(), EXCELLON_WRITER::createDrillFile(), MICROWAVE_TOOL::createFootprint(), SCH_GLOBALLABEL::CreateGraphicShape(), SCH_DIRECTIVE_LABEL::CreateGraphicShape(), PNS::OPTIMIZER::customBreakouts(), KIGFX::PCB_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), PCB_DIMENSION_BASE::drawAnArrow(), KIGFX::CAIRO_GAL_BASE::DrawArc(), KIGFX::CAIRO_GAL_BASE::DrawArcSegment(), drawBacksideTicks(), CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText(), DrawHalfOpenCylinder(), AR_MATRIX::drawSegmentQcq(), drawTicksAlongLine(), GBR_TO_PCB_EXPORTER::export_segarc_copper_item(), EXPORTER_PCB_VRML::ExportVrmlFootprint(), fillArcPOLY(), CADSTAR_ARCHIVE_PARSER::FixTextPositionNoAlignment(), GERBER_PLOTTER::FlashPadChamferRoundRect(), GERBER_PLOTTER::FlashPadCustom(), HPGL_PLOTTER::FlashPadOval(), PSLIKE_PLOTTER::FlashPadOval(), HPGL_PLOTTER::FlashPadRect(), PSLIKE_PLOTTER::FlashPadRect(), DXF_PLOTTER::FlashPadRect(), DXF_PLOTTER::FlashPadTrapez(), GERBER_PLOTTER::FlashPadTrapez(), HPGL_PLOTTER::FlashPadTrapez(), PSLIKE_PLOTTER::FlashPadTrapez(), GERBER_PLOTTER::FlashRegularPolygon(), GENCAD_EXPORTER::FootprintWriteShape(), PCB_IO_KICAD_SEXPR::format(), formatInternalUnits(), GERBER_DRAW_ITEM::GetABPosition(), EDA_SHAPE::GetArcMid(), SCH_LABEL::GetBodyBoundingBox(), SCH_FIELD::GetBoundingBox(), SCH_TEXT::GetBoundingBox(), BOX2< Vec >::GetBoundingBoxRotated(), DS_DATA_ITEM_POLYGONS::GetCornerPosition(), PCB_TEXTBOX::GetDrawPos(), KIGFX::PREVIEW::ARC_GEOM_MANAGER::GetEndRadiusEnd(), BOARD_ITEM::GetFPRelativePosition(), CADSTAR_PCB_ARCHIVE_LOADER::getKiCadPad(), EDA_TEXT::GetLinePositions(), CADSTAR_SCH_ARCHIVE_LOADER::getLocationOfNetElement(), KIGEOM::GetOvalKeyPoints(), getRectangleAlongCentreLine(), GetRotated(), KIGFX::PREVIEW::ARC_GEOM_MANAGER::GetStartRadiusEnd(), KIFONT::OUTLINE_FONT::getTextAsGlyphsUnlocked(), ARRAY_CIRCULAR_OPTIONS::GetTransform(), GERBER_DRAW_ITEM::GetXYPosition(), GRCSegm(), hash_fp_item(), ALTIUM_PCB::HelperParseDimensions6Center(), ALTIUM_PCB::HelperParseDimensions6Leader(), ALTIUM_PCB::HelperSetTextAlignmentAndPos(), ALTIUM_PCB::HelperSetTextboxAlignmentAndPos(), idf_export_footprint(), RENDER_3D_RAYTRACE_BASE::insertHole(), CIRCLE::Intersect(), BOX2< Vec >::Intersects(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadArc(), PCB_IO_EAGLE::loadPlain(), SCH_IO_EAGLE::loadRectangle(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances(), SCH_IO_EAGLE::loadSymbolRectangle(), CADSTAR_SCH_ARCHIVE_LOADER::loadSymdef(), STEP_PCB_MODEL::MakeShapeAsThickSegment(), DSN::mapPt(), FOOTPRINT::MoveAnchorPosition(), PCB_TABLE::Normalize(), OVAL::OVAL(), PCB_IO_EAGLE::packageCircle(), ALTIUM_PCB::ParseComponentsBodies6Data(), PCB_IO_EASYEDAPRO_PARSER::ParseContour(), GPCB_FPL_CACHE::parseFOOTPRINT(), PCB_IO_EASYEDA_PARSER::ParseToBoardItemContainer(), SCH_TEXT::Plot(), BRDITEMS_PLOTTER::PlotPadNumber(), GERBER_PLOTTER::plotRoundRectAsRegion(), BRDITEMS_PLOTTER::PlotText(), SCH_TEXT::Print(), FABMASTER::processArc(), SHAPE_ARC::Rotate(), SHAPE_LINE_CHAIN::Rotate(), EDIT_TOOL::Rotate(), SCH_BUS_ENTRY_BASE::Rotate(), SCH_FIELD::Rotate(), SCH_JUNCTION::Rotate(), SCH_LABEL_BASE::Rotate(), SCH_LINE::Rotate(), SCH_NO_CONNECT::Rotate(), SCH_SHEET::Rotate(), SCH_SHEET_PIN::Rotate(), SCH_SYMBOL::Rotate(), SCH_TEXT::Rotate(), REFERENCE_IMAGE::Rotate(), EDA_SHAPE::rotate(), FOOTPRINT::Rotate(), PCB_TUNING_PATTERN::Rotate(), PAD::Rotate(), PCB_DIMENSION_BASE::Rotate(), PCB_GENERATOR::Rotate(), PCB_TARGET::Rotate(), PCB_TEXT::Rotate(), PCB_TRACK::Rotate(), PCB_ARC::Rotate(), SCH_PIN::RotatePin(), RotatePoint(), EDA_SHAPE::SetArcAngleAndEnd(), DS_DATA_ITEM_POLYGONS::SetBoundingBox(), BOARD_ITEM::SetFPRelativePosition(), SHAPE_ARC::SHAPE_ARC(), PAD::ShapePos(), PLOTTER::sketchOval(), KIGFX::PCB_PAINTER::strokeText(), PNS_KICAD_IFACE_BASE::syncPad(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testShapeLineChain(), PDF_PLOTTER::Text(), AR_MATRIX::TraceFilledRectangle(), DIALOG_PAD_PROPERTIES::transferDataToPad(), PCB_IO_EAGLE::transferPad(), KIFONT::STROKE_GLYPH::Transform(), PIN_LAYOUT_CACHE::transformBoxForPin(), TransformCircleToPolygon(), TransformEllipseToBeziers(), TransformOvalToPolygon(), PAD::TransformShapeToPolygon(), EASYEDA_PARSER_BASE::TransformTextToBaseline(), PNS::MEANDER_SHAPE::turn(), PCB_DIM_RADIAL::updateGeometry(), PCB_DIM_CENTER::updateGeometry(), PAD_POINT_EDIT_BEHAVIOR::UpdateItem(), PCB_DIM_ALIGNED::updateText(), KIGFX::PREVIEW::RULER_ITEM::ViewDraw(), and GERBER_PLOTTER::writeApertureList().
void RotatePoint | ( | int * | pX, |
int * | pY, | ||
int | cx, | ||
int | cy, | ||
const EDA_ANGLE & | aAngle | ||
) |
Calculate the new point of coord coord pX, pY, for a rotation center cx, cy.
Definition at line 267 of file trigo.cpp.
References RotatePoint().
Definition at line 114 of file trigo.h.
References RotatePoint(), VECTOR2< T >::x, and VECTOR2< T >::y.
Definition at line 121 of file trigo.h.
References RotatePoint(), VECTOR2< T >::x, and VECTOR2< T >::y.
Rotate a VECTOR2I in place by aAngle about aCentre.
Definition at line 92 of file trigo.h.
References RotatePoint(), VECTOR2< T >::x, and VECTOR2< T >::y.
Rotate a VECTOR2I in place by aAngle.
Definition at line 69 of file trigo.h.
References RotatePoint(), VECTOR2< T >::x, and VECTOR2< T >::y.
bool SegmentIntersectsSegment | ( | const VECTOR2I & | a_p1_l1, |
const VECTOR2I & | a_p2_l1, | ||
const VECTOR2I & | a_p1_l2, | ||
const VECTOR2I & | a_p2_l2, | ||
VECTOR2I * | aIntersectionPoint = nullptr |
||
) |
Test if two lines intersect.
a_p1_l1 | The first point of the first line. |
a_p2_l1 | The second point of the first line. |
a_p1_l2 | The first point of the second line. |
a_p2_l2 | The second point of the second line. |
aIntersectionPoint | is filled with the intersection point if it exists |
Definition at line 107 of file trigo.cpp.
References KiROUND(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by BOX2< Vec >::Intersects().
bool TestSegmentHit | ( | const VECTOR2I & | aRefPoint, |
const VECTOR2I & | aStart, | ||
const VECTOR2I & | aEnd, | ||
int | aDist | ||
) |
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
aRefPoint | = reference point to test |
aStart | is the first end-point of the line segment |
aEnd | is the second end-point of the line segment |
aDist | = maximum distance for hit |
Definition at line 175 of file trigo.cpp.
References std::abs(), delta, SEG::Square(), SEG::SquaredDistance(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by SCH_IO_EAGLE::addBusEntries(), EE_GRID_HELPER::computeAnchors(), DRAWING_TOOL::DrawVia(), EDA_SHAPE::hitTest(), SCH_BUS_ENTRY_BASE::HitTest(), SCH_LINE::HitTest(), DS_DRAW_ITEM_LINE::HitTest(), DS_DRAW_ITEM_RECT::HitTest(), PCB_TRACK::HitTest(), GERBER_DRAW_ITEM::HitTest(), SCH_IO_EAGLE::moveLabels(), SHAPE_LINE_CHAIN::Simplify(), and SCH_LABEL_BASE::UpdateDanglingState().