| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
| 9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
| 10 * disclaimer. | 10 * disclaimer. |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 211 |
| 212 bool FloatPolygon::contains(const FloatPoint& point) const { | 212 bool FloatPolygon::contains(const FloatPoint& point) const { |
| 213 if (!m_boundingBox.contains(point)) | 213 if (!m_boundingBox.contains(point)) |
| 214 return false; | 214 return false; |
| 215 return (fillRule() == RULE_NONZERO) ? containsNonZero(point) | 215 return (fillRule() == RULE_NONZERO) ? containsNonZero(point) |
| 216 : containsEvenOdd(point); | 216 : containsEvenOdd(point); |
| 217 } | 217 } |
| 218 | 218 |
| 219 bool VertexPair::intersection(const VertexPair& other, | 219 bool VertexPair::intersection(const VertexPair& other, |
| 220 FloatPoint& point) const { | 220 FloatPoint& point) const { |
| 221 // See: http://paulbourke.net/geometry/pointlineplane/, "Intersection point of
two lines in 2 dimensions" | 221 // See: http://paulbourke.net/geometry/pointlineplane/, |
| 222 // "Intersection point of two lines in 2 dimensions" |
| 222 | 223 |
| 223 const FloatSize& thisDelta = vertex2() - vertex1(); | 224 const FloatSize& thisDelta = vertex2() - vertex1(); |
| 224 const FloatSize& otherDelta = other.vertex2() - other.vertex1(); | 225 const FloatSize& otherDelta = other.vertex2() - other.vertex1(); |
| 225 float denominator = determinant(thisDelta, otherDelta); | 226 float denominator = determinant(thisDelta, otherDelta); |
| 226 if (!denominator) | 227 if (!denominator) |
| 227 return false; | 228 return false; |
| 228 | 229 |
| 229 // The two line segments: "this" vertex1,vertex2 and "other" vertex1,vertex2,
have been defined | 230 // The two line segments: "this" vertex1,vertex2 and "other" vertex1,vertex2, |
| 230 // in parametric form. Each point on the line segment is: vertex1 + u * (verte
x2 - vertex1), | 231 // have been defined in parametric form. Each point on the line segment is: |
| 231 // when 0 <= u <= 1. We're computing the values of u for each line at their in
tersection point. | 232 // vertex1 + u * (vertex2 - vertex1), when 0 <= u <= 1. We're computing the |
| 233 // values of u for each line at their intersection point. |
| 232 | 234 |
| 233 const FloatSize& vertex1Delta = vertex1() - other.vertex1(); | 235 const FloatSize& vertex1Delta = vertex1() - other.vertex1(); |
| 234 float uThisLine = determinant(otherDelta, vertex1Delta) / denominator; | 236 float uThisLine = determinant(otherDelta, vertex1Delta) / denominator; |
| 235 float uOtherLine = determinant(thisDelta, vertex1Delta) / denominator; | 237 float uOtherLine = determinant(thisDelta, vertex1Delta) / denominator; |
| 236 | 238 |
| 237 if (uThisLine < 0 || uOtherLine < 0 || uThisLine > 1 || uOtherLine > 1) | 239 if (uThisLine < 0 || uOtherLine < 0 || uThisLine > 1 || uOtherLine > 1) |
| 238 return false; | 240 return false; |
| 239 | 241 |
| 240 point = vertex1() + uThisLine * thisDelta; | 242 point = vertex1() + uThisLine * thisDelta; |
| 241 return true; | 243 return true; |
| 242 } | 244 } |
| 243 | 245 |
| 244 } // namespace blink | 246 } // namespace blink |
| OLD | NEW |