KEEP K.I.S.S.

tk's blog

Ruby 的小角度7参数转换简单描述

tk posted @ Jan 11, 2012 01:58:22 PM in Ruby , 1938 阅读

小角度7参数转换的 Ruby 使用 Matrix的简单描述

小角度的7参数坐标系转换可以化简原本的转换参数公式,最后如下图片描述

 

 

这是一段根据3个点对的坐标来求解转换额外一点的对应坐标的 Ruby代码,使用了Ruby标准库里的 Matrix,很方便的:

 

require 'matrix'

def buildBUnit(*p)
  a = []
  a[0, 7] = 1, 0, 0, p[0], 0, -p[2], p[1]
  a[7, 7] = 0, 1, 0, p[1], p[2], 0, -p[0]
  a[14, 7] = 0, 0, 1, p[2], -p[1], p[0], 0
  a
end

def cutDown(*p, count)
  a = []
  row = 0
  while row < (p.count.to_f / count).ceil
    a << p[row * count, count]
    row += 1
  end
  a
end

def buildB(*p)
  a = []
  p.each {|point| a += buildBUnit(*point) }
  Matrix[*(cutDown(*a, 7))]
end

def buildA(*p)
  Matrix.column_vector(p.flatten)
end

m = [[ 30.55876333, 117.2395818, 13.09], [30.55882632, 117.23958408, 13.188], [ 30.55876333, 117.23968333, 13.09]]
p = [[13.127, -3.579, 10.143], [13.090, 3.434, 10.200], [3.127, -3.579, 10.143]]
B = buildB(*p)
A = buildA(*m)

BT = B.transpose
temp = BT * B
X = temp.inv * BT * A

bas = [47.850, -0.020, 3.399]
trans = Matrix[*cutDown(*buildBUnit(*bas), 7)]
MM = trans * X
p MM

#够简单的。。。。
  • 无匹配
  • 无匹配
BSNL Fiber plans 说:
Aug 10, 2022 01:58:39 AM

BSNL is installing Bharat Net a country-wide fiber optic cable for internet connectivity in many of the panchayats, and on the other hand, ISP brought the same fibernet technology to your doorstep directly and through TIPs. BSNL Fiber plans Telecom Infrastructure Providers (TIPs) with new Fiber plans covering many isolated pockets in all BSNL circles of the country for 50Mbps to 300 Mbps internet speed on providing with BSNL FTTH Plans along with FREE ONT as per the possibility.

Comprar Pentobarbita 说:
Feb 18, 2023 10:50:27 PM

As a seller of legal steroids, you can buy Crazy Bulk products, explore stacks and finally get the body you’ve always wanted Comprar Pentobarbital Sódico

buy clenbuterol 说:
Mar 09, 2023 09:57:33 PM

I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details. buy clenbuterol

xmanager spotify and 说:
Mar 24, 2023 06:26:08 AM

The worst part of it was that the software only worked intermittently and the data was not accurate. You obviously canot confront anyone about what you have discovered if the information is not right. xmanager spotify android

Secret Headquarters 说:
Apr 27, 2023 06:18:35 AM

very interesting post.this is my first time visit here.i found so many interesting stuff in your blog especially its discussion..thanks for the post! high da backlinks

ahrefs dr 说:
Jul 22, 2023 06:09:37 AM

Your link building service is worth every penny. The authoritative backlinks you've secured have boosted my website's authority and visibility. I appreciate the transparency and regular reporting on the progress. Highly recommended for effective link building ahrefs dr

tech 说:
Dec 04, 2023 02:08:19 AM

Took me time to understand all of the comments, but I seriously enjoyed the write-up. It proved being really helpful to me and Im positive to all of the commenters right here! Its constantly nice when you can not only be informed, but also entertained! I am certain you had enjoyable writing this write-up. UFABETแจกเครดิตฟรี


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter