示例#1
0
文件: imp.go 项目: CaptainSoOmA/Uni
func start(x, y, z, xf, yf, zf float64) {
	//
	v, n := vectors(1)
	init1(v, n, x, y, z)  // Auge
	n[0].Set3(xf, yf, zf) // Fokus
	pts.Ins(pt.Start, 1, v, n, col.Black)
}
示例#2
0
文件: imp.go 项目: CaptainSoOmA/Uni
func segment(x, y, z, x1, y1, z1 float64, c col.Colour) {
	//
	v, n := vectors(2)
	init2(v, n, x, y, z, x1, y1, z1)
	pts.Ins(pt.Lines, 2, v, n, c)
	ready()
}
示例#3
0
文件: imp.go 项目: CaptainSoOmA/Uni
func light(l uint, x, y, z float64, ca, cd col.Colour) {
	//
	v, n := vectors(1)
	v[0].Set3(x, y, z)
	n[0].Set3(0.0, 0.0, 1.0)
	//  r, g, b:= col.LongFloat (ca)
	n[0].Set3(col.LongFloat(ca)) // r, g, b // ambient colour
	pts.Ins(pt.Light, l, v, n, cd)
}
示例#4
0
文件: imp.go 项目: CaptainSoOmA/Uni
func sphere(x, y, z, r float64, c col.Colour) {
	//
	v, n := vectors(N + 2)
	v[0].Set3(x, y, z+r)
	n[0].Set3(0.0, 0.0, 1.0)
	r0 := r * sin[1]
	z0 := z + r*cos[1]
	for l := 0; l <= N; l++ {
		v[1+l].Set3(x+r0*cos[l], y+r0*sin[l], z0)
		n[1+l].Set3(sin[1]*cos[l], sin[1]*sin[l], cos[1])
	}
	pts.Ins(pt.TriangleFan, N+2, v, n, c)
	v, n = vectors(2 * (N + 1))
	for b := 1; b <= N/2-2; b++ {
		r0 = r * sin[b]
		z0 = z + r*cos[b]
		r1 := r * sin[b+1]
		z1 := z + r*cos[b+1]
		for l := 0; l <= N; l++ {
			v[2*l].Set3(x+r0*cos[l], y+r0*sin[l], z0)
			n[2*l].Set3(sin[b]*cos[l], sin[b]*sin[l], cos[b])
			v[2*l+1].Set3(x+r1*cos[l], y+r1*sin[l], z1)
			n[2*l+1].Set3(sin[b+1]*cos[l], sin[b+1]*sin[l], cos[b+1])
		}
		pts.Ins(pt.QuadStrip, 2*N+2, v, n, c)
	}
	v, n = vectors(N + 2)
	v[0].Set3(x, y, z-r)
	n[0].Set3(0.0, 0.0, -1.0)
	b := N/2 - 1
	r0 = r * sin[b]
	z0 = z + r*cos[b]
	for l := N; l >= 0; l -= 1 {
		v[1+N-l].Set3(x+r0*cos[l], y+r0*sin[l], z0)
		n[1+N-l].Set3(sin[b]*cos[l], sin[b]*sin[l], cos[b])
	}
	pts.Ins(pt.TriangleFan, N+2, v, n, c)
	ready()
}
示例#5
0
文件: imp.go 项目: CaptainSoOmA/Uni
func horRectangle(x, y, z, x1, y1 float64, up bool, c col.Colour) {
	//
	v, n := vectors(4)
	init4(v, n, x, y, z, x1, y, z, x1, y1, z, x, y1, z)
	nachOben := 1.0
	if !up {
		nachOben = -1.0
	}
	for i := 0; i <= 3; i++ {
		n[i].Set3(0.0, 0.0, nachOben)
	}
	pts.Ins(pt.Quads, 4, v, n, c)
}
示例#6
0
文件: imp.go 项目: CaptainSoOmA/Uni
func quad(x, y, z, x1, y1, z1, x2, y2, z2, x3, y3, z3 float64, c col.Colour) {
	//
	v, n := vectors(4)
	init4(v, n, x, y, z, x1, y1, z1, x2, y2, z2, x3, y3, z3)
	n[1].Sub(v[1], v[0])
	n[2].Sub(v[3], v[0])
	n[0].Ext(n[1], n[2])
	n[0].Norm()
	for i := 1; i <= 3; i++ {
		n[i].Copy(n[0])
	}
	pts.Ins(pt.Quads, 4, v, n, c)
}
示例#7
0
文件: imp.go 项目: CaptainSoOmA/Uni
func triangle(x, y, z, x1, y1, z1, x2, y2, z2 float64, c col.Colour) {
	//
	v, n := vectors(3)
	init3(v, n, x, y, z, x1, y1, z1, x2, y2, z2)
	n[1].Sub(v[1], v[0])
	n[2].Sub(v[2], v[0])
	n[0].Ext(n[1], n[2])
	n[0].Norm()
	for i := 1; i <= 2; i++ {
		n[i].Copy(n[0])
	}
	pts.Ins(pt.Triangles, 3, v, n, c)
}
示例#8
0
文件: imp.go 项目: CaptainSoOmA/Uni
func cone(x, y, z, r, h float64, c col.Colour) {
	//
	v, n := vectors(N + 2)
	v[0].Set3(x, y, z+h)
	n[0].Set3(0.0, 0.0, 1.0)
	for l := 0; l <= N; l++ {
		v[l+1].Set3(x+r*cos[l], y+r*sin[l], z)
		n[l+1].Set3(cos[l], sin[l], r/(h-z))
		n[l+1].Norm()
	}
	pts.Ins(pt.TriangleFan, N+2, v, n, c)
	ready()
	circle(x, y, z, -r, c)
}
示例#9
0
文件: imp.go 项目: CaptainSoOmA/Uni
func vertRectangle(x, y, z, x1, y1, z1 float64, c col.Colour) {
	//
	v, n := vectors(4)
	if z == z1 {
		ker.Stop(pack, 1)
	} // horRectangle
	init4(v, n, x, y, z, x1, y1, z, x1, y1, z1, x, y, z1)
	n[1].Sub(v[1], v[0])
	n[2].Sub(v[3], v[0])
	n[0].Ext(n[1], n[2])
	n[0].Norm()
	for i := 1; i <= 3; i++ {
		n[i].Copy(n[0])
	}
	pts.Ins(pt.Quads, 4, v, n, c)
}
示例#10
0
文件: imp.go 项目: CaptainSoOmA/Uni
func cylinderSegment(x, y, z, r, h, a, b float64, c col.Colour) {
	//
	circleSegment(x, y, z, -r, a, b, c)
	circleSegment(x, y, z+h, r, a, b, c)
	A := uint(math.Floor(a/float64(angle) + 0.5))
	B := uint(math.Floor(b/float64(angle) + 0.5))
	C := 2*(B-A) + 2
	v, n := vectors(C)
	for l := A; l <= B; l++ {
		v[2*(l-A)].Set3(x+r*cos[l], y+r*sin[l], z)
		n[2*(l-A)].Set3(cos[l], sin[l], 0.0)
		v[2*(l-A)+1].Set3(x+r*cos[l], y+r*sin[l], z+h)
		n[2*(l-A)+1].Set3(cos[l], sin[l], 0.0)
	}
	pts.Ins(pt.QuadStrip, C, v, n, c)
	ready()
}
示例#11
0
文件: imp.go 项目: CaptainSoOmA/Uni
func frustum(x, y, z, r, h, h1 float64, c col.Colour) {
	//
	if h1 > h {
		ker.Stop(pack, 4)
	}
	v, n := vectors(N + 2)
	v[0].Set3(x, y, h)
	n[0].Set3(0.0, 0.0, 1.0)
	for l := 0; l <= N; l++ {
		v[l+1].Set3(x+r*cos[l], y+r*sin[l], z)
		n[l+1].Set3(cos[l], sin[l], r/(h-z))
		n[l+1].Norm()
	}
	pts.Ins(pt.TriangleFan, N+2, v, n, c)
	ready()
	circle(x, y, z, -r, c)
}
示例#12
0
文件: imp.go 项目: CaptainSoOmA/Uni
func vertCircle(x, y, z, r, a float64, f col.Colour) {
	//
	if r == 0.0 {
		point(x, y, z, f)
		return
	}
	s, c := math.Sin(a*um), math.Cos(a*um)
	C := uint(N) + 2
	v, n := vectors(C)
	v[0].Set3(x, y, z)
	n[0].Set3(c, s, 0.0)
	if r < 0.0 {
		r = -r
		n[0].Dilate(-1.0)
	}
	for i := 0; i <= N; i++ {
		v[i+1].Set3(x-r*s*cos[i], y+r*c*cos[i], z+r*sin[i])
		n[i+1].Copy(n[0])
	}
	pts.Ins(pt.TriangleFan, C, v, n, f)
	ready()
}
示例#13
0
文件: imp.go 项目: CaptainSoOmA/Uni
func circleSegment(x, y, z, r, a, b float64, c col.Colour) {
	//
	if r == 0.0 {
		point(x, y, z, c)
		return
	}
	A := uint(math.Floor(a/float64(angle) + 0.5))
	B := uint(math.Floor(b/float64(angle) + 0.5))
	C := B - A + 2
	v, n := vectors(C)
	v[0].Set3(x, y, z)
	n[0].Set3(0.0, 0.0, 1.0)
	if r < 0. {
		r = -r
		n[0].Dilate(-1.0)
	}
	for i := A; i <= B; i++ {
		v[1+i-A].Set3(x+r*cos[i], y+r*sin[i], z)
		n[1+i-A].Copy(n[0])
	}
	pts.Ins(pt.TriangleFan, C, v, n, c)
	ready()
}
示例#14
0
文件: imp.go 项目: CaptainSoOmA/Uni
func horCylinder(x, y, z, r, l, a float64, f col.Colour) {
	//
	if r == 0.0 {
		vertCircle(x, y, z, r, a, f)
		return
	}
	s, c := math.Sin(a*um), math.Cos(a*um)
	dx, dy := l*c, l*s
	vertCircle(x, y, z, -r, a, f)
	vertCircle(x+dx, y+dy, z, r, a, f)
	C := 2 * (uint(N) + 1)
	v, n := vectors(C)
	for i := 0; i <= 2*N; i += 2 {
		si, ci := sin[i/2], cos[i/2]
		sci, cci := s*ci, c*ci
		x0, y0, z0 := x-r*sci, y+r*cci, z+r*si
		v[i].Set3(x0, y0, z0)
		n[i].Set3(-sci, cci, si)
		v[i+1].Set3(x0+dx, y0+dy, z0)
		n[i+1].Copy(n[i])
	}
	pts.Ins(pt.QuadStrip, C, v, n, f)
	ready()
}
示例#15
0
文件: imp.go 项目: CaptainSoOmA/Uni
func point(x, y, z float64, c col.Colour) {
	//
	v, n := vectors(1)
	init1(v, n, x, y, z)
	pts.Ins(pt.Points, 1, v, n, c)
}
示例#16
0
文件: imp.go 项目: CaptainSoOmA/Uni
func ready() {
	//
	v, n := vectors(1)
	pts.Ins(pt.None, 1, v, n, col.Black)
}