1 // Copyright 2016 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef ASH_FAST_INK_LASER_LASER_SEGMENT_UTILS_H_ 6 #define ASH_FAST_INK_LASER_LASER_SEGMENT_UTILS_H_ 7 8 #include <vector> 9 10 #include "ash/ash_export.h" 11 12 namespace gfx { 13 class PointF; 14 class Vector2dF; 15 } // namespace gfx 16 17 namespace ash { 18 19 // Compute the angle in radians of |point|, with |origin| as the origin and 20 // |direction| as the x-axis. In other words, computes the angle in radians 21 // between |direction| and |point| - |origin|. 22 float ASH_EXPORT AngleOfPointInNewCoordinates(const gfx::PointF& origin, 23 const gfx::Vector2dF& direction, 24 const gfx::PointF& point); 25 26 // Compute the variables for the equation of the lines normal to the line 27 // segment formed by |start_point| and |end_point|, and which run through the 28 // endpoints of that line segment. The outputs will be returned as NaN if the 29 // line segment is parallel to the x-axis (undefined normal lines). 30 void ASH_EXPORT ComputeNormalLineVariables(const gfx::PointF& start_point, 31 const gfx::PointF& end_point, 32 float* normal_slope, 33 float* start_y_intercept, 34 float* end_y_intercept); 35 36 // Compute the two the projections of |point| along the line defined by 37 // |line_slope| and |line_y_intercept|. The distance of each projection is 38 // |projection_distance| from |point|. 39 void ASH_EXPORT ComputeProjectedPoints(const gfx::PointF& point, 40 float line_slope, 41 float line_y_intercept, 42 float projection_distance, 43 gfx::PointF* first_projection, 44 gfx::PointF* second_projection); 45 46 // Checks if the angle of |first_point| is smaller than the angle of 47 // |second_point|. These angles are computed relative to the coordinate system 48 // defined by the midpoint of |start_point| and |end_point|, with the x-axis 49 // as |end_point| - |start_point|. 50 bool ASH_EXPORT IsFirstPointSmallerAngle(const gfx::PointF& start_point, 51 const gfx::PointF& end_point, 52 const gfx::PointF& first_point, 53 const gfx::PointF& second_point); 54 55 } // namespace ash 56 57 #endif // ASH_FAST_INK_LASER_LASER_SEGMENT_UTILS_H_ 58