如何确定边缘在3d中是凹还是凸?

时间:2015-06-03 13:02:22

标签: c++ vector 3d angle

我正在使用C ++中的OpenMesh库。我有一个函数,无论边是凹还是凸,都应该返回。

document.getElementById('showTest').style.display = 'none';

(function() {
var showText1 = 4, // Stop play at time in seconds
    showTextTimer;   // Reference to settimeout call
var hideText1 = 6, // Stop play at time in seconds
    hideTextTimer;   // Reference to settimeout call    

// This code loads the IFrame Player API code asynchronously.
var tag = document.createElement("script");
tag.src = "//www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName("script")[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

// This function creates an <iframe> (and YouTube player)
// after the API code downloads.
var player;
window.onYouTubeIframeAPIReady = function() {
  player = new YT.Player("player", {
    "height": "315",
    "width": "560",
    "videoId": "L6cVcbkx8l8",
    "events": {
    "onReady": onPlayerReady,
    "onStateChange": onPlayerStateChange
  }
});
}

// The API will call this function when the video player is ready.
// This automatically starts the video playback when the player is loaded.
function onPlayerReady(event) {
  event.target.playVideo();
}

// The API calls this function when the player's state changes.
function onPlayerStateChange(event) {
  var time, rate, remainingTime, remainingTime2;
  if (event.data == YT.PlayerState.PLAYING) {
    time = player.getCurrentTime();
    rate = player.getPlaybackRate();  
    // Add .4 of a second to the time in case it's close to the current time
    // (The API kept returning ~9.7 when hitting play after stopping at 10s)
    if (time + .4 < showText1) {
      remainingTime = (showText1 - time) / rate;
      showTextTimer = setTimeout(showTxt, remainingTime * 1000);
    }
    if (time + .4 < hideText1) {
      remainingTime2 = (hideText1 - time) / rate;
      hideTextTimer = setTimeout(hideTxt, remainingTime2 * 1000);
    }          
  }
  else {
        clearTimeout(showTextTimer);
        clearTimeout(hideTextTimer);
  }
}
function showTxt() {
  document.getElementById('showTest').style.display = 'block';
}
function hideTxt() {
  document.getElementById('showTest').style.display = 'none';
}    
})();

其中函数angleBetweenVectors(Vec3f,Vec3f)实现为

bool isConcave(HalfedgeHandle initial, Mesh & mesh){ FaceHandle face1 = mesh.face_handle(initial); FaceHandle face2 = mesh.face_handle(mesh.opposite_halfedge_handle(initial)); long double angle = angleBetweenVectors(mesh.calc_face_normal(face1), mesh.calc_face_normal(face2)); if (angle >= (M_PI/2)){ cout << "Convex " << (angle * RADIANS_TO_DEGREES) << "\n"; return false;} else{ cout << "Concave " << (angle * RADIANS_TO_DEGREES) << "\n"; return true;}}

但是当我在OpenMesh上的tutorial中构建的立方体的各个边缘上运行它时,我的输出为“凹面0”和“凸面90”,此时所有边都应该是凸面90.为什么是我的输出不正确?

1 个答案:

答案 0 :(得分:1)

好吧,万一其他人想知道,因为我意识到了这个问题......

立方体是三角形网格。因此,立方体的每个面实际上被分成两个三角形面。因此,某些面在技术上是平行的,这些面之间的角度为0度。