【この訳に特有な表記規約】
この訳において(主にアルゴリズム内で)利用される各種記号( ε, ← , IF, THROW, 等々)の意味や定義の詳細は、共通な慣用表現, アルゴリズムに共通して利用される表記を参照されたし。
1. 序論
Accelerometer
,
LinearAccelerationSensor
,
GravitySensor
API は、
汎用センサー API ( Generic Sensor API ) [GENERIC-SENSOR] インタフェースを拡張して,device により定義される局所座標系における device の[
X , Y , Z
]軸に適用される加速度についての情報を供する。
The Accelerometer, LinearAccelerationSensor and GravitySensor APIs extends the Generic Sensor API [GENERIC-SENSOR] interface to provide information about acceleration applied to device’s X, Y and Z axis in local coordinate system defined by device.
2. 例
let sensor = new Accelerometer(); sensor.start(); sensor.onreading = () => { console.log("X 軸方向の加速度: " + sensor.x); console.log("Y 軸方向の加速度: " + sensor.y); console.log("Z 軸方向の加速度: " + sensor.z); } sensor.onerror = event => console.log(event.error.name, event.error.message);
スクリーン座標系内の読み取りを供する重力センサーを利用する方法を次の例に示す。 スクリーン方位が地面に垂直で,描画された web ページの下端が下方を指しているとき、 このコード片は,コンソールにメッセージを print することになる。 The following example shows how to use gravity sensor that provides readings in the screen coordinate system. The snippet will print message to the console when the dom screen is perpendicular to the ground and bottom of the rendered web page is pointing downwards.
let sensor = new GravitySensor({frequency: 5, referenceFrame: "screen"}); sensor.onreading = () => { if (sensor.y >= 9.8) { console.log("Web ページは地面に垂直です。"); } } sensor.start();
次の例は、 スクリーン方位に関わらず, x 軸方向の device の揺れ(ジェスチャなど)を検出する。 The following example detects shake gesture along x axis of the device, regardless of the orientation of the dom screen.
const shakeThreshold = 25; let sensor = new LinearAccelerationSensor({frequency: 60}); sensor.addEventListener('reading', () => { if (sensor.x > shakeThreshold) { console.log("揺れが検出されました。"); } }); sensor.start();
3. 利用事例と要件
利用事例/要件は、 次に挙げられている :[MOTION-SENSORS] § 利用事例と要件, センサーの利用事例 The use cases and requirements are listed in the Motion Sensors Explainer and Sensor use cases documents.
4. セキュリティ/プライバシーの考慮点
加速度計などの慣性センサーにより供されたセンサー読み取りは、 様々なセキュリティ脅威を悪用する敵対者により利用され得る — 例えば :キーをログする, 所在を追跡する, device を指紋収集する, 利用者を識別する Sensor readings provided by inertial sensors, such as accelerometer, could be used by adversaries to exploit various security threats, for example, keylogging, location tracking, fingerprinting and user identifying.
セキュリティコミュニティにより公表された論文 — 一例として [KEYSTROKEDEFENSE] — は、 frequency を絞っても,攻撃が成功するリスクを全部的には排せない一方で、 センサーを正当な理由で利用している web アプリの有用性には,大きく影響し得ることを指示している。 Research papers published by security community, for instance, [KEYSTROKEDEFENSE], indicate that by throttling the frequency, risks of successful attacks are not fully eliminated, while throttling may greatly affect usefulness of a web application with legitimate reasons to use the sensors.
[TOUCHSIGNATURES], [ACCESSORY] 論文は、 次を提案する: 実装は[ 慣性センサーが利用中にあるときに視覚的な指示を供する/ センサー読み取りにアクセスするためには明示的に利用者の同意を要求する ]ことができる。 これらの軽減策は、 汎用センサー API [GENERIC-SENSOR] に定義される 汎用な軽減策を補う。 The [TOUCHSIGNATURES] and [ACCESSORY] research papers propose that implementations can provide visual indication when inertial sensors are in use and/or require explicit user consent to access sensor readings. These mitigation strategies complement the generic mitigations defined in the Generic Sensor API [GENERIC-SENSOR].
この仕様は、[ センサー較正指紋収集 [SENSORID], 高精度なセンサー読み取りに依拠する攻撃 ]を軽減するためとして,加速度計の読み取り量子化アルゴリズムを定義する (最新な読み取りマップから値を取得する演算から call される)。 量子化アルゴリズムの詳細は、 W3C Privacy Interest Group による推奨に従う。 This specification defines an accelerometer reading quantization algorithm (called from the get value from latest reading operation) to mitigate sensor calibration fingerprinting [SENSORID] and attacks that rely on high precision sensor readings. The details of the quantization algorithm follow W3C Privacy Interest Group’s recommendation.
5. 許可施策の統合
この仕様は、
文字列 "accelerometer
" により識別される施策により制御される特能を用立てる
— それは、
[DEVICE-ORIENTATION] にて定義される。
This specification utilizes the policy-controlled feature identified by the string "accelerometer" defined in [DEVICE-ORIENTATION].
6. モデル
6.1. 加速度計
センサー型 加速度計 ( Accelerometer )には、 次に挙げるデータが結び付けられる: The Accelerometer sensor type has the following associated data:
-
拡張センサーインタフェース
:
Accelerometer
Extension sensor interface • Accelerometer -
センサー許可名群
:{ "
accelerometer
" } Sensor permission names • "accelerometer" -
センサー特能名群
:{ "
accelerometer
" } Sensor feature names • "accelerometer" -
許可取り消しアルゴリズム
:次を呼び出す
:センサー許可取り消しアルゴリズム( "
accelerometer
" ) Permission revocation algorithm • Invoke the generic sensor permission revocation algorithm with "accelerometer". - 既定のセンサー :当の device の main 加速度計センサー Default sensor • The device’s main accelerometer sensor.
-
属する virtual センサー型
:"
accelerometer
" Virtual sensor type • "accelerometer"
センサー型 加速度計 の Sensor
用の最新な読み取りマップは[
"x
", "y
", "z
"
]を key とする 3 個のエントリを含む。
それらの各値は、
対応する軸における device の加速度を包含する。
A latest reading for a Sensor of Accelerometer sensor type includes three entries whose keys are "x", "y", "z" and whose values contain device’s acceleration about the corresponding axes.
加速度 ( acceleration )は、 device の速度における,時間に対する変化率である。 その単位は、 m/s2 [SI] ( metre per second squared )とする。 The acceleration is the rate of change of velocity of a device with respect to time. Its unit is the metre per second squared (m/s2) [SI].
加速度の測定用の基準フレームは、 慣性系でなければならない — 自由落下している device は、 各軸の加速度値に 0 m/s2 を供することになるような。 The frame of reference for the acceleration measurement must be inertial, such as, the device in free fall would provide 0 (m/s2) acceleration value for each axis.
加速度値の符号は、 局所座標系において右手系に則るものとする(下の図を見よ)。 The sign of the acceleration values must be according to the right-hand convention in a local coordinate system (see figure below).
加速度計の座標系。 Accelerometer coordinate system.
6.2. 線形加速度センサー
センサー型 線形加速度計センサー ( Linear Acceleration Sensor ) には、 次に挙げるデータが結び付けられる: The Linear Acceleration Sensor sensor type has the following associated data:
-
拡張センサーインタフェース
:
LinearAccelerationSensor
Extension sensor interface • LinearAccelerationSensor -
センサー許可名群
:{ "
accelerometer
" } Sensor permission names • "accelerometer" -
センサー特能名群
:{ "
accelerometer
" } Sensor feature names • "accelerometer" -
許可取り消しアルゴリズム
:次を呼び出す
:センサー許可取り消しアルゴリズム( "
accelerometer
" ) Permission revocation algorithm • Invoke the generic sensor permission revocation algorithm with "accelerometer". -
属する virtual センサー型
:"
linear-acceleration
" Virtual sensor type • "linear-acceleration"
センサー型 線形加速度計センサー の Sensor
用の最新な読み取りマップは[
"x
", "y
", "z
"
]を key とする 3 個のエントリを含む。
それらの各値は、
対応する軸における device の線形加速度を包含する。
A latest reading for a Sensor of Linear Acceleration Sensor sensor type includes three entries whose keys are "x", "y", "z" and whose values contain device’s linear acceleration about the corresponding axes.
線形加速度 ( linear acceleration )は、 センサーをホストしている device に適用される[ 重力の寄与を含まない,加速度 ]である。 The linear acceleration is an acceleration that is applied to the device that hosts the sensor, without the contribution of a gravity force.
注記: 重力と線形加速度の関係性は、 [MOTION-SENSORS] § 重力センサーと線形加速度センサー にて論じられている。 Note: The relationship between gravity and linear acceleration is discussed in Motion Sensors Explainer § gravity-and-linear-acceleration.
6.3. 重力センサー
センサー型 重力センサー ( Gravity Sensor )には、 次に挙げるデータが結び付けられる: The Gravity Sensor sensor type has the following associated data:
-
拡張センサーインタフェース
:
GravitySensor
Extension sensor interface • GravitySensor -
センサー許可名群
:{ "
accelerometer
" } Sensor permission names • "accelerometer" -
センサー特能名群
:{ "
accelerometer
" } Sensor feature names • "accelerometer" -
許可取り消しアルゴリズム
:次を呼び出す
:センサー許可取り消しアルゴリズム( "
accelerometer
" ) Permission revocation algorithm • Invoke the generic sensor permission revocation algorithm with "accelerometer". -
属する virtual センサー型
:"
gravity
" Virtual sensor type • "gravity"
センサー型 重力センサー の Sensor
用の最新な読み取りマップは[
"x
", "y
", "z
"
]を key とする 3 個のエントリを含む。
それらの各値は、
対応する軸における重力に因る加速度を包含する。
A latest reading for a Sensor of Gravity Sensor sensor type includes three entries whose keys are "x", "y", "z" and whose values contain the acceleration due to gravity about the corresponding axes.
重力 ( gravity / gravity force )は、 device の加速度の[ 近くの質量体【平たく言えば,地球の中心】へ向かって速度が増加するのに抗する成分 ]である。 短時間でない限り,自由落下している device において算出される重力は,不正な値になり得る。 The gravity is the component of the device’s acceleration that prevents its velocity from increasing toward nearby masses. Devices in free fall for more than a short period of time may compute incorrect values for the gravity.
注記: 重力と線形加速度の関係性は、 [MOTION-SENSORS] § 重力センサーと線形加速度センサー にて論じられている。 Note: The relationship between gravity and linear acceleration is discussed in Motion Sensors Explainer § gravity-and-linear-acceleration.
6.4. 基準フレーム
局所座標系は、[
Accelerometer
/
LinearAccelerationSensor
/
GravitySensor
]センサー読み取り用の基準フレームを表現する。
それは、
device 座標系にもスクリーン座標系にもなり得る。
The local coordinate system represents the reference frame for the Accelerometer, LinearAccelerationSensor, and the GravitySensor readings. It can be either the device coordinate system or the screen coordinate system.
device 座標系 ( device coordinate system )は、 物理的 device に束縛された 3 次元の直交座標系として定義される。 ディスプレイを伴う device 用には,device 座標系の:
- 原点は device ディスプレイの中心とする。
-
device が,その既定の姿勢に保持されている下では:
- Y 軸は ディスプレイの上端を指す。
- X 軸は ディスプレイの右端を指す。
- Z 軸は[ X 軸, Y 軸 ]のクロス積であり,ディスプレイから閲覧者へ向かう方を指す
device 座標系は【 device のディスプレイに相対的な】スクリーン方位に関わらず,stationary であり続ける(下の図を見よ)。
The device coordinate system is defined as a three dimensional Cartesian coordinate system (x, y, z), which is bound to the physical device. For devices with a display, the origin of the device coordinate system is the center of the device display. If the device is held in its default position, the Y-axis points towards the top of the display, the X-axis points towards the right of the display and Z-axis is the vector product of X and Y axes and it points outwards from the display, and towards the viewer. The device coordinate system remains stationary regardless of the dom screen orientation (see figure below).device 座標系。 Device coordinate system.
スクリーン座標系 ( screen coordinate system )は、 【 device のディスプレイに相対的な】スクリーン方位に束縛された 3 次元の直交座標系として定義される — スクリーン座標系の:
- 原点は、 スクリーンの中心にある。
- Y 軸は、 常にスクリーンの上端を指す。
- X 軸は、 スクリーンの右端を指す。
- Z 軸は、 X 軸, Y 軸のクロス積であり,スクリーンから閲覧者へ向かう方を指す(下の図を見よ)。
スクリーン座標系。 Screen coordinate system.
device 座標系とスクリーン座標系の主な相違は、 後者は常にスクリーン方位に従うことにある — すなわち,スクリーンの現在の方位種別が変化した場合,それに応じて X 軸, Y 軸が入れ替わることになる。 対照的に,device 座標系は、 常に device に相対的に stationary であり続ける。 The main difference between the device coordinate system and the screen coordinate system, is that the screen coordinate system always follows the dom screen orientation, i.e. it will swap X and Y axes in relation to the device if the current orientation type changes. In contrast, the device coordinate system will always remain stationary relative to the device.
7. API
7.1. Accelerometer
インタフェース
[SecureContext, Exposed=Window] interfaceAccelerometer
:Sensor
{constructor
(optionalAccelerometerSensorOptions
options = {}); readonly attribute double?x
; readonly attribute double?y
; readonly attribute double?z
; }; enumAccelerometerLocalCoordinateSystem
{ "device
", "screen
" }; dictionaryAccelerometerSensorOptions
:SensorOptions
{AccelerometerLocalCoordinateSystem
referenceFrame
= "device"; };
new Accelerometer(options)
構築子手続きは
:加速度計オブジェクトを構築する( これ°, options )
The new Accelerometer(options) constructor steps are to invoke the construct an accelerometer object abstract operation with this and options.
Accelerometer
がサポートするセンサーオプション群は
:"frequency
", "referenceFrame
"
Supported sensor options for Accelerometer are "frequency" and "referenceFrame".
[
x
/ y
/ z
]属性は、[
x / y / z
]軸方向の加速度を表現する。
↓
x
取得子手続きは
:RETURN 最新な読み取りマップから値を取得する( これ°, "x
" )
7.1.1. Accelerometer.xThe x attribute of the Accelerometer interface returns the result of invoking get value from latest reading with this and "x" as arguments.\
It represents the acceleration along x-axis.y
取得子手続きは
:RETURN 最新な読み取りマップから値を取得する( これ°, "y
" )
7.1.2. Accelerometer.yThe y attribute of the Accelerometer interface returns the result of invoking get value from latest reading with this and "y" as arguments.\
It represents the acceleration along y-axis.z
取得子手続きは
:RETURN 最新な読み取りマップから値を取得する( これ°, "z
" )
7.1.3. Accelerometer.zThe z attribute of the Accelerometer interface returns the result of invoking get value from latest reading with this and "z" as arguments.\
It represents the acceleration along z-axis.7.2. LinearAccelerationSensor
インタフェース
[SecureContext, Exposed=Window] interfaceLinearAccelerationSensor
:Accelerometer
{constructor
(optionalAccelerometerSensorOptions
options = {}); };
new LinearAccelerationSensor(options)
構築子手続きは
:加速度計オブジェクトを構築する( これ°, options )
The new LinearAccelerationSensor(options) constructor steps are to invoke the construct an accelerometer object abstract operation with this and options.
LinearAccelerationSensor
がサポートするセンサーオプション群は
:"frequency
", "referenceFrame
"
Supported sensor options for LinearAccelerationSensor are "frequency" and "referenceFrame".
LinearAccelerationSensor
の[
x
/ y
/ z
]属性は、[
x / y / z
]軸方向の線形加速度を表現する。
↓
x
取得子手続きは
:RETURN 最新な読み取りマップから値を取得する( これ°, "x
" )
7.2.1. LinearAccelerationSensor.xThe x attribute of the LinearAccelerationSensor interface returns the result of invoking get value from latest reading with this and "x" as arguments.\
It represents the linear acceleration along x-axis.y
取得子手続きは
:RETURN 最新な読み取りマップから値を取得する( これ°, "y
" )
7.2.2. LinearAccelerationSensor.yThe y attribute of the LinearAccelerationSensor interface returns the result of invoking get value from latest reading with this and "y" as arguments.\
It represents the linear acceleration along y-axis.z
取得子手続きは
:RETURN 最新な読み取りマップから値を取得する( これ°, "z
" )
7.2.3. LinearAccelerationSensor.zThe z attribute of the LinearAccelerationSensor interface returns the result of invoking get value from latest reading with this and "z" as arguments.\
It represents the linear acceleration along z-axis.7.3. GravitySensor
インタフェース
[SecureContext, Exposed=Window] interfaceGravitySensor
:Accelerometer
{constructor
(optionalAccelerometerSensorOptions
options = {}); };
new GravitySensor(options)
構築子手続きは
:加速度計オブジェクトを構築する( これ°, options )
The new GravitySensor(options) constructor steps are to invoke the construct an accelerometer object abstract operation with this and options.
GravitySensor
がサポートするセンサーオプション群は
:"frequency
", "referenceFrame
"
Supported sensor options for GravitySensor are "frequency" and "referenceFrame".
GravitySensor
の[
x
/ y
/ z
]属性は、
重力に因る[
x / y / z
]軸方向の加速度の効果を表現する。
↓
x
取得子手続きは
:RETURN 最新な読み取りマップから値を取得する( これ°, "x
" )
7.3.1. GravitySensor.xThe x attribute of the GravitySensor interface returns the result of invoking get value from latest reading with this and "x" as arguments.\
It represents the effect of acceleration along x-axis due to gravity.y
取得子手続きは
:RETURN 最新な読み取りマップから値を取得する( これ°, "y
" )
7.3.2. GravitySensor.yThe y attribute of the GravitySensor interface returns the result of invoking get value from latest reading with this and "y" as arguments.\
It represents the effect of acceleration along y-axis due to gravity.z
取得子手続きは
:RETURN 最新な読み取りマップから値を取得する( これ°, "z
" )
7.3.3. GravitySensor.zThe z attribute of the GravitySensor interface returns the result of invoking get value from latest reading with this and "z" as arguments.\
It represents the effect of acceleration along z-axis due to gravity.8. 抽象演算
加速度計オブジェクトを構築する アルゴリズムは、 所与の ( オブジェクト, オプション群 ) に対し: 8.1. Construct an accelerometer object ↓
-
Assert:
オブジェクト は
Accelerometer
インタフェースを実装する input • object, an Accelerometer, LinearAccelerationSensor or GravitySensor object. -
Assert:
オプション群 は
AccelerometerSensorOptions
辞書である • options, a AccelerometerSensorOptions object. -
IF[
センサー施策により制御される特能を検査する( オブジェクト のセンサー型 ) = false
]
:THROW
SecurityError
Let allowed be the result of invoking check sensor policy-controlled features with object’s sensor type.If allowed is false, then: • Throw a SecurityError DOMException. - センサーオブジェクトを初期化する( オブジェクト, オプション群 ) Invoke initialize a sensor object with object and options.
-
オブジェクト の局所座標系を オプション群[ "
referenceFrame
" ] に応じて, 次になるものと定義する :"screen
" ならば スクリーン座標系/ "device
" ならば device 座標系 If options.referenceFrame is "screen", then: • Set object’s local coordinate system to the screen coordinate system.Otherwise, define object’s local coordinate system to the device coordinate system.
センサー型 加速度計 は、 読み取り量子化アルゴリズムとして次を定義する — それは、 所与の ( センサー読み取り 読み取り ) に対し,センサー読み取りを返す: 8.2. Accelerometer reading quantization algorithmThe Accelerometer sensor type defines the following reading quantization algorithm:input • reading, a sensor reading output • A sensor reading
-
( x, y, z ) :← ( 読み取り[ "
x
" ], 読み取り[ "y
" ], 読み取り[ "z
" ] ) ↓ - 量子化された読み取り :← 読み取り Let quantizedReading be reading.
-
IF[
x ≠ null
]
:量子化された読み取り[ "
x
" ] ← x に最も近い 0.1 m/s2 の倍数 If quantizedReading["x"] is not null, set quantizedReading["x"] to the nearest 0.1 m/s2. -
IF[
y ≠ null
]
:量子化された読み取り[ "
y
" ] ← y に最も近い 0.1 m/s2 の倍数 If quantizedReading["y"] is not null, set quantizedReading["y"] to the nearest 0.1 m/s2. -
IF[
z ≠ null
]
:量子化された読み取り[ "
z
" ] ← z に最も近い 0.1 m/s2 の倍数 If quantizedReading["z"] is not null, set quantizedReading["z"] to the nearest 0.1 m/s2. - RETURN 量子化された読み取り Return quantizedReading.
9. 自動化
この節では、 [GENERIC-SENSOR] に定義される自動化を拡張する — 加速度計 に特有な virtual センサーメタデータを供することにより。 この仕様により利用される virtual センサー型のうち一部は、 [DEVICE-ORIENTATION] にて定義される。 This section extends Generic Sensor API § 9 Automation by providing Accelerometer-specific virtual sensor metadata. Some of the virtual sensor types used by this specification are defined in [DEVICE-ORIENTATION].
9.1. 加速度計の自動化
加速度計 が属する virtual センサー型 "accelerometer
",
それに対応する[
型ごとの virtual センサーメタデータを成すエントリ
]は、
[DEVICE-ORIENTATION] § 自動化
にて定義される。
The accelerometer virtual sensor type and its corresponding entry in the per-type virtual sensor metadata map are defined in Device Orientation and Motion § automation.
9.2. 線形加速度計の自動化
線形加速度計センサー が属する virtual センサー型 "linear-acceleration
",
それに対応する[
型ごとの virtual センサーメタデータを成すエントリ
]は、
[DEVICE-ORIENTATION] § 自動化
にて定義される。
The linear-acceleration virtual sensor type and its corresponding entry in the per-type virtual sensor metadata map are defined in Device Orientation and Motion § automation.
9.3. 重力センサーの自動化
型ごとの virtual センサーメタデータを与えるマップは、 次に挙げるエントリを伴うものとする: The per-type virtual sensor metadata map must have the following entry:
-
key "
gravity
" :対応する値を与える virtual センサーメタデータの :読み取り構文解析アルゴリズムは xyz の読み取りを構文解析する key • "gravity" value • A virtual sensor metadata whose reading parsing algorithm is parse xyz reading.
謝辞
Tobie Langel 氏による, 汎用センサー API の作業に。 Tobie Langel for the work on Generic Sensor API.
W3C Privacy Interest Group, Paul Jensen 氏による, センサー較正指紋収集の軽減提案, その論点に。 W3C Privacy Interest Group and Paul Jensen for the sensor calibration fingerprinting mitigation proposal and discussion.