Movatterモバイル変換


[0]ホーム

URL:


Appendix B: Implementation Notes

B.1. Introduction

The following notes describe algorithms and other strategieswhich can be used by software developers when converting contentto and from the formats required by features in the SVG language.

B.2. Elliptical arc parameter conversion

To be consistent with other path segment notation,arcs in SVG paths are defined in terms of start and end points on the curve.

This parameterization of elliptical arcs will be referred toasendpoint parameterization. One of theadvantages of endpoint parameterization is that it permits aconsistent path syntax in which all path commands end in thecoordinates of the new "current point".

However, this is not the only way of describing arc geometryused in software or mathematics.This section describes the alternative center parameterization,and how to convert it from and to SVG's endpoint parameterization.

B.2.1. Elliptical arc endpoint syntax

An elliptical arc, as represented in the SVG path command,is described by the following parameters in order:

(x1y1) are the absolute coordinates of thecurrent point on the path, obtained from the last twoparameters of the previous path command.

rxandryare the radii of the ellipse (also known as its semi-major andsemi-minor axes).

φ is the angle from the x-axis of the current coordinatesystem to the x-axis of the ellipse.

fA isthe large arc flag, and is 0if an arc spanning less than or equal to 180 degrees is chosen, or 1if an arc spanning greater than 180 degrees is chosen.

fS isthe sweep flag, and is 0 ifthe line joining center to arc sweeps through decreasingangles, or 1 if it sweepsthrough increasing angles.

(x2y2) are the absolute coordinates of thefinal point of the arc.

B.2.2. Parameterization alternatives

An arbitrary point (xy) on the ellipticalarc can be described by the 2-dimensional matrix equation:

(eq. 3.1)
(xy)=(cosφ-sinφsinφcosφ)·(rxcosθrysinθ)+(cxcy)
    x = rx*cos(θ)*cos(φ) - ry*sin(θ)*sin(φ) + cx    y = rx*cos(θ)*sin(φ) + ry*sin(θ)*cos(φ) + cy

(cxcy) arethe coordinates of the center of the ellipse.

rx andryare the radii of the ellipse (also known as its semi-major andsemi-minor axes).

φ is the angle from thex-axis of the current coordinate system to the x-axis of theellipse.

θ is the angle around the arc that the point(xy) lies at, and ranges from:

If one thinks of an ellipse as a circle that has beenstretched and then rotated, thenθ1,θ2 and Δθare the start angle, end angle and sweep angle, respectivelyof the arc prior to the stretch and rotate operations.This leads to an alternate parameterization which is commonamong graphics APIs, which will be referred to ascenterparameterization. In the next sections, formulas aregiven for mapping in both directions between centerparameterization and endpoint parameterization.

B.2.3. Conversion from center to endpoint parameterization

Given the following variables:

cxcyrxryφθ1 Δθ

the task is to find:

x1y1x2y2fAfS

This can be achieved using the following formulas:

x1y1=cosφ-sinφsinφcosφrx cosθ1ry sinθ1+cxcy
(eq. 4.1)
x2y2=cosφ-sinφsinφcosφrx cosθ1+Δθry sinθ1+Δθ+cxcy
(eq. 4.2)
fA=1  if  Δθ>180°0  if  Δθ180°
(eq. 4.3)
fS=1  if  Δθ > 0°0  if  Δθ < 0°
(eq. 4.4)

B.2.4. Conversion from endpoint to center parameterization

Given the following variables:

x1y1x2y2fAfSrxryφ

the task is to find:

cxcyθ1 Δθ

The equations simplify after a translation whichplaces the origin at the midpoint of the line joining(x1y1) to(x2y2), followed bya rotation to line up the coordinate axes with the axes of the ellipse.All transformed coordinates will be written with primes. They arecomputed as intermediate values on the way toward finding the requiredcenter parameterization variables. This procedure consists of thefollowing steps:

B.2.5. Correction of out-of-range radii

This section describes the mathematical adjustments required for out-of-rangerx andry,as described in thePath implementation notes.Algorithmically these adjustments consist of the followingsteps:

B.3. Notes on generating high-precision geometry

This section is informative.

Thereal number precision of SVG issingle-precision.conforming SVG generators handling technical datawhere expression of information exceeding single precision is desired,such as maps and technical drawings,are encouraged to follow the process outlined in this sectionto ensure consistent display inconforming SVG viewers.

Presentation with an effective precision higher thansingle-precision may be obtained by taking advantageof the fact that at least double-precision floating point must be usedwhen generating a CTM (See CTM generation processing in theConforming SVG Viewers section).The steps for generating content that takes advantage of this are:

  1. Split content into tiles such that the number of significant digits required to position and size each object within a tile is within the range of single precision floats. Besides, in this description, the coordinate system which the original content has originally will be called source space.
  2. Generate a coordinate transformation matrix per tile to transform from source space to tile space, where tile space is a coordinate system with origin(0,0) at the top left of the tile. Each element of the transformation matrix must be within the range of single precision.
  3. Transform the contents of each tile from source space to tile space using the generated coordinate transformation matrix. The result is that the parameters of each object can now be expressed with significant digits within the range of single precision floats.
  4. For each tile, generate an inverse transformation matrix for the conversion of tile space to source space. This is used as atransform attribute of the element for the tile of the next step.
  5. Arrange each tile as a separate user coordinate system in SVG. For example, the tiles may be expressed ag elements with antransform attribute having the transformation matrix generated by the previous step. And the split graphics generated by the third step will be placed as children of it.
Example Splitting vector graphics bigger than a tile
Before Splitting     After Splitting
Example Before splitting     Example After Splitting
Example Improving Significant Digits
Step 1 : Splitting content     Step 5 : Arranging tiles with smaller effective digits and appropriate translate
Example Split content into tiles     Example Translate and assign split contents
This example provides the significant figure of eight digits using tiles with the user coordinate system of seven digits.

[8]ページ先頭

©2009-2025 Movatter.jp