zoukankan      html  css  js  c++  java
  • cgal 线面相交,线线相交

    简介

    快速用库的方式得到交点

    参考链接

    https://blog.csdn.net/OOFFrankDura/article/details/82430434

    code

    //山东大学 计算机基地Frankdura
    //2018.9.4
    #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
    #include <CGAL/intersections.h>
    typedef CGAL::Exact_predicates_exact_constructions_kernel K;
    typedef K::Point_3 Point_3;
    typedef K::Segment_3 Segment_3;
    typedef K::Plane_3 Plane_3;
    typedef K::Intersect_3 Intersect_3;
    int main()
    {
        Segment_3 seg(Point_3(0,0,0), Point_3(2,2,0));
        Segment_3 lin(Point_3(1,2,0), Point_3(1,0,0));
    
    
        CGAL::cpp11::result_of<Intersect_3(Segment_3, Segment_3)>::type
                result = intersection(seg, lin);
            if (result) {
            if (const Segment_3* s = boost::get<Segment_3>(&*result)) {
                std::cout << *s << std::endl;
            } else {
                const Point_3* p = boost::get<Point_3 >(&*result);
                std::cout << (*p) << std::endl;
            }
        }
        return 0;
    }
    
    #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
    #include <CGAL/intersections.h>
    typedef CGAL::Exact_predicates_exact_constructions_kernel K;
    typedef K::Point_3 Point_3;
    typedef K::Segment_3 Segment_3;
    typedef K::Plane_3 Plane_3;
    typedef K::Intersect_3 Intersect_3;
    int main()
    {
        Segment_3 seg(Point_3(0,0,0), Point_3(4,4,4));
        Plane_3 lin (Point_3(1,0,0),Point_3(0,1,0),Point_3(0,0,1));
        CGAL::cpp11::result_of<Intersect_3(Segment_3, Segment_3)>::type
                result = intersection(seg, lin);
            if (result) {
            if (const Segment_3* s = boost::get<Segment_3>(&*result)) {
                std::cout << *s << std::endl;
            } else {
                const Point_3* p = boost::get<Point_3 >(&*result);
                std::cout << (*p) << std::endl;
            }
        }
        return 0;
    }
    

    附赠Makefile

    LOCAL_LIBRARY +=  -L/home/ling/lee/lib/cgal/dyna
    LOCAL_LDFLAGS += -lm -lpthread -ldl -lCGAL_Core -lCGAL_ImageIO -lCGAL -lgmp -lmpfr
    LOCAL_CFLAGS += -I/home/ling/lee/include
    CC := g++ -g -std=c++17
    TARGETS1 = genCube2
    SRCS1 = main2.cc
    OBJS1 = $(patsubst %.cc, %.o, $(SRCS1))
    
    CFLAGS += $(LOCAL_CFLAGS)
    LDFLAGS += $(LOCAL_LIBRARY) $(LOCAL_LDFLAGS)
    
    $(info $(OBJS))
    $(info $(TARGETS))
    
    all: $(TARGETS1)
    
    
    $(TARGETS1):$(OBJS1)
    	$(CC)  -o $@ $^  $(LDFLAGS) $(CFLAGS)
    
    $(OBJS1): %.o:%.cc
    	$(CC) -c $< -o $@ $(CFLAGS)
    
    clean :
    	@rm -rf $(TARGETS1) $(OBJS1)
    
    #.SUFFIXES:
    .PHONY : all clean
    
    Hope is a good thing,maybe the best of things,and no good thing ever dies.----------- Andy Dufresne
  • 相关阅读:
    apue 第19章 伪终端
    apue 第18章 终端I/O
    linux IPC socket(2)
    linux IPC socket
    linux POSIX信号量
    【Luogu】【关卡2-16】线性动态规划(2017年10月)【还差三道题】
    【Luogu】【关卡2-15】动态规划的背包问题(2017年10月)【还差一道题】
    【Luogu】【关卡2-14】 树形数据结构(2017年10月)【AK】
    【Luogu】【关卡2-13】线性数据结构(2017年10月)【还差一道题】
    【Luogu】【关卡2-12】递推与递归二分(2017年10月)
  • 原文地址:https://www.cnblogs.com/eat-too-much/p/13675403.html
Copyright © 2011-2022 走看看