3D空间的直线能否只用四个变量来表达?

三个座标 x, y, z 可以确定3D空间的任意一点。

形如 x + y + z = 1, 的方程可以表示3d 空间的一个平面, 该平面与x, y, z轴的交点分别为(1, 0, 0), (0, 1, 0), (0, 0, 1) 三个点,那么推广到一般情形, ax + by + cz = d, (a, b, c, d 为四个变量),当a, b, c, d都给定时,可以唯一的确定3 D空间的任意一个平面,对于3d 空间的直线能否也只用四个变量,来唯一的确定这条直线呢?

对于3D中的直线来说,有几种表示法,用了六个变量的两点式,用3D直线上两个点来确定该直线。
用了八个变量的两平面相交的方式。
{(x,y,z)∈R3:a1x+b1y+c1z=d1 and a2x+b2y+c2z=d2}.

用六个变量的点斜式
Here are three ways to describe the formula of a line in 3 dimensions. Let’s assume the line L passes through the point (x0,y0,z0) and is traveling in the direction (a,b,c).

(x,y,z)=(x0,y0,z0)+t(a,b,c) (这里的 t 不是变量)

https://math.stackexchange.com/questions/404440/what-is-the-equation-for-a-3d-line

还有用了六个变量的投影式
a X + b Y + c = 0 (3d直线从 z 轴投影的XY平面的一般式 2D 直线方程)
d X + e Z + f = 0 (3d直线从 y 轴投影的XZ平面的一般式 2D 直线方程)
https://blog.codingnow.com/2006/12/eioaeoeiessiecea.html

研究一下three.js的源代码,在Plane.js 中发现其对平面的抽象,非常优美,非常好用,也是只用了四个变量,就能唯一确定 3d 空间的任意平面,分别是平面的法向量normal, 和constantconstant表示该平面沿着法向量指定的方向位移多少距离,使得座标系原点(0,0,0)落在该平面上

/**
 * @author bhouston / http://clara.io
 */

function Plane( normal, constant ) {

	// normal is assumed to be normalized

	this.normal = ( normal !== undefined ) ? normal : new Vector3( 1, 0, 0 );
	this.constant = ( constant !== undefined ) ? constant : 0;

}

three.js 中对于3D 直线的抽象,不太令我满意,使用的是两点式,Line3.js

/**
 * @author bhouston / http://clara.io
 */

function Line3( start, end ) {

	this.start = ( start !== undefined ) ? start : new Vector3();
	this.end = ( end !== undefined ) ? end : new Vector3();

}

还有射线,Ray.js,使用的点斜式

/**
 * @author bhouston / http://clara.io
 */

function Ray( origin, direction ) {

	this.origin = ( origin !== undefined ) ? origin : new Vector3();
	this.direction = ( direction !== undefined ) ? direction : new Vector3();

}

射线没啥好说的,用六个变量是合适的

用六个变量来表示3D线段也是很合适的,而用六个变量来表示3D直线是不是太多了,
可以这样用五个变量来表示3D直线,设任意3D 直线L,
直线L可以唯一的确定一个平面 P,平面 P的法向量和L平行,而且平面 P正好过原点,这样平面P就只用了三个变量(x,y,z)可以表示,(x,y,z)是平面 P的法向量,平面 P的constant 始终为 0,这里constant不算变量,直线L 和 平面 P的交点是个二维座标 (n, m), 这样就用了五个变量(x, y, z, n, m)确定 任意3D 直线L

还能不能更少点?只用四个变量来确定 任意3D 直线,或者说用数学来证明根本不可能用四个变量来确定 任意3D 直线 ?

jscolor.js 源码中的片段,
判断字体颜色是否应该应用黑色背景

this.isLight = function () {
			return (
				0.213 * this.rgb[0] +
				0.715 * this.rgb[1] +
				0.072 * this.rgb[2] >
				255 / 2
			);
		};

rgb颜色明暗度变化的实现思路
先把rgb 转换为hsv (色度,饱和度,明暗度)颜色,调整hsv 中 v,最后把hsv 转换为rgb

// r: 0-255
		// g: 0-255
		// b: 0-255
		//
		// returns: [ 0-360, 0-100, 0-100 ]
		//
		function RGB_HSV (r, g, b) {
			r /= 255;
			g /= 255;
			b /= 255;
			var n = Math.min(Math.min(r,g),b);
			var v = Math.max(Math.max(r,g),b);
			var m = v - n;
			if (m === 0) { return [ null, 0, 100 * v ]; }
			var h = r===n ? 3+(b-g)/m : (g===n ? 5+(r-b)/m : 1+(g-r)/m);
			return [
				60 * (h===6?0:h),
				100 * (m/v),
				100 * v
			];
		}
		
// h: 0-360
		// s: 0-100
		// v: 0-100
		//
		// returns: [ 0-255, 0-255, 0-255 ]
		//
		function HSV_RGB (h, s, v) {
			var u = 255 * (v / 100);

			if (h === null) {
				return [ u, u, u ];
			}

			h /= 60;
			s /= 100;

			var i = Math.floor(h);
			var f = i%2 ? h-i : 1-(h-i);
			var m = u * (1 - s);
			var n = u * (1 - s * f);
			switch (i) {
				case 6:
				case 0: return [u,n,m];
				case 1: return [n,u,m];
				case 2: return [m,u,n];
				case 3: return [m,n,u];
				case 4: return [n,m,u];
				case 5: return [u,m,n];
			}
		}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章