/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
/** * rPnt.X/rPnt.Y is set to rCenter.X or rCenter.Y! * We then only need to rotate rPnt by rCenter. * * @return the returned angle is in rad
*/ inlinedouble GetCrookAngle(Point& rPnt, const Point& rCenter, const Point& rRad, bool bVertical);
/** * The following methods accept a point of an XPolygon, whereas the neighbouring * control points of the actual point are passed in pC1/pC2. * Via rSin/rCos, sin(nAngle) and cos(nAngle) are returned. * * @return the returned angle is in rad
*/ double CrookRotateXPoint(Point& rPnt, Point* pC1, Point* pC2, const Point& rCenter, const Point& rRad, double& rSin, double& rCos, bool bVert); double CrookSlantXPoint(Point& rPnt, Point* pC1, Point* pC2, const Point& rCenter, const Point& rRad, double& rSin, double& rCos, bool bVert); double CrookStretchXPoint(Point& rPnt, Point* pC1, Point* pC2, const Point& rCenter, const Point& rRad, double& rSin, double& rCos, bool bVert, const tools::Rectangle& rRefRect);
/** * The Y axis points down! * The function negates the Y axis, when calculating the angle, such * that GetAngle(Point(0,-1))=90 deg. * GetAngle(Point(0,0)) returns 0. * * @return the returned value is in the range of -180.00..179.99 deg * and is in 1/100 deg units
*/
SVXCORE_DLLPUBLIC Degree100 GetAngle(const Point& rPnt);
SVXCORE_DLLPUBLIC Degree100 NormAngle18000(Degree100 a); /// Normalize angle to -180.00..179.99
SVXCORE_DLLPUBLIC Degree100 NormAngle36000(Degree100 a); /// Normalize angle to 0.00..359.99
sal_uInt16 GetAngleSector(Degree100 nAngle); /// Determine sector within the cartesian coordinate system
/** * Calculates the length of (0,0) via a^2 + b^2 = c^2 * In order to avoid overflows, we ignore some decimal places.
*/
tools::Long GetLen(const Point& rPnt);
/** * The transformation of a rectangle into a polygon, by * using angle parameters from GeoStat. ------------ * The point of reference is always the Point 0, meaning /1 2/ * the upper left corner of the initial rectangle. / / * When calculating the polygon, the order is first / / * shear and then the rotation. / / * / / \ * / / | * A) Initial rectangle aRect B) After applying Shear /0 3/ Rot| * +------------------+ -------------------- ------------------ * |0 1| \0 1\ C) After applying Rotate * | | \ \ * | | | \ \ * |3 2| | \3 2\ * +------------------+ | -------------------- * |Shr * * When converting the polygon back into a rect, the order is necessarily the * other way around: * - Calculating the rotation angle: angle of the line 0-1 in figure C) to the horizontal * - Turning the sheared rect back (we get figure B) * - Determining the width of the rect = length of the line 0-1 in figure B) * - Determining the height of the rect = vertical distance between the points 0 and 3 * of figure B) * - Determining the shear angle from the line 0-3 to the perpendicular line. * * We need to keep in mind that the polygon can be mirrored when it was * transformed in the meantime (e.g. mirror or resize with negative factor). * In that case, we first need to normalize, by swapping points (0 with 3 and 1 * with 2), so that it has the right orientation. * * Note: a positive shear angle means a shear with a positive visible curvature * on the screen. Mathematically, that would be a negative curvature, as the * Y axis runs from top to bottom on the screen. * Rotation angle: positive means a visible left rotation.
*/
class GeoStat { // Geometric state for a rect public:
Degree100 m_nRotationAngle;
Degree100 m_nShearAngle; double mfTanShearAngle; // tan(nShearAngle) double mfSinRotationAngle; // sin(nRotationAngle) double mfCosRotationAngle; // cos(nRotationAngle)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.