Exemplo n.º 1
0
func (r *Receiver) PanView(pos, delta glm.Vec2d) {
	theta := delta.Mul(r.Constants.PanSensitivity * r.Constants.Fov)

	turnV := glm.QuatRotated(theta[1], gtk.ToVec3D(r.UIState.TiltAxis))
	turnH := glm.QuatRotated(-theta[0], gtk.ToVec3D(r.UIState.PanAxis))

	r.UIState.Orientation = turnH.Mul(r.UIState.Orientation).Mul(turnV)
}
Exemplo n.º 2
0
func (c *BezierCurve) quadApprox(p1, c1, c2, p2 mathgl.Vec2d) (v mathgl.Vec2d, ok bool) {
	//P2 - 3·C2 + 3·C1 - P1
	d01 := p2.Sub(c2.Mul(3)).Add(c1.Mul(3)).Sub(p1).Len() / 2
	if d01 <= gQuadraticApproxPrecision {
		// (3·C2 - P2 + 3·C1 - P1)/4
		return c2.Mul(3).Sub(p2).Add(c1.Mul(3)).Sub(p1).Mul(1 / 4.), true
	}
	return v, false
}
Exemplo n.º 3
0
func (r *Receiver) PanView(pos, delta glm.Vec2d) {
	theta := delta.Mul(r.Constants.PlayerFOV * r.Constants.PlayerPanSensitivity)

	turnV := glm.QuatRotated(theta[1], gtk.ToVec3D(r.Player.TiltAxis))
	turnH := glm.QuatRotated(-theta[0], gtk.ToVec3D(r.Player.PanAxis))

	r.Player.OrientationH = turnH.Mul(r.Player.OrientationH)
	r.Player.Orientation = turnH.Mul(r.Player.Orientation).Mul(turnV)

	r.Invalid = true
}
Exemplo n.º 4
0
func mid(v1 mathgl.Vec2d, v2 mathgl.Vec2d) mathgl.Vec2d {
	return v1.Add(v2).Mul(1 / 2.)
}