我怎么能只调用我的功能翻译,旋转等?

时间:2016-04-11 18:06:43

标签: matlab affinetransform

你好,我有一个功能和一个问题:)

var quotesArr = ["Quote 1", "Quote 2", "Quote 3"];

var authorsArr = ["Author 1", "Author 2", "Author 3"];

var quoteMeetsAuthor = [];

var quotesAndAuthors = [];


function combineArrays(quotes,authors) {
  if (quotes.length != authors.length) {
    console.log("Danger Will Robinson!");
    return "Danger Will Robinson!";
  }

  for (i=0; i<quotes.length; i++) {
    quoteMeetsAuthor.push(quotes[i]);
    quoteMeetsAuthor.push(authors[i]);
    quotesAndAuthors.push(quoteMeetsAuthor);
    quoteMeetsAuthor = [];
  }
  console.log(quotesAndAuthors);
  return quotesAndAuthors;
}

combineArrays(quotesArr, authorsArr);

我应该使用这个函数(transform_vertices)只是ONCE旋转,翻译,但我怎么能只使用一次?我的代码是

function[result] = transform_vertices(v, m)
    for i = 1 : size(v,2)
        v(:,i) = m * v(:,i); 
    end
    result = v;
end

1 个答案:

答案 0 :(得分:0)

我认为quad是一组坐标?您的transform_vertices函数只会执行左矩阵乘法。如果你这样做,你会得到相同的结果:

image1_vertices = transform_vertices(quad, mtranslate(-2,0)*mrotate(30));

事实上,你甚至不需要使用这个功能,你可以这样做:

image1_vertices = mtranslate(-2,0) * mrotate(30) * quad;