当前位置: 首页>>代码示例>>C++>>正文


C++ InterfaceList::size方法代码示例

本文整理汇总了C++中InterfaceList::size方法的典型用法代码示例。如果您正苦于以下问题:C++ InterfaceList::size方法的具体用法?C++ InterfaceList::size怎么用?C++ InterfaceList::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在InterfaceList的用法示例。


在下文中一共展示了InterfaceList::size方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: runABM

ReflectPair runABM(int nSamples, double azimuthalAngle, 
        double polarAngle, bool disableSieve, InterfaceList &interfaceList) {
    int startState;
    int reflectedState;
    int transmittedState;
    int absorbedState = -2;
    int numReflected   = 0;
    int numTransmitted = 0;
    int numAbsorbed    = 0;

    double sp = sin(polarAngle);
    vec3 startingPosition(
        cos(azimuthalAngle)*sp,
        sin(azimuthalAngle)*sp,
        cos(polarAngle)
    );

    startingPosition.z *= -1; /* Leaf interfaces are listed adaxial-first, 
                                 orientation is generally assumed with respect to abaxial */

    if(startingPosition.z < 0) {
        startState = 0;
        reflectedState = -1;
        transmittedState = interfaceList.size();
    } else {
        startState = interfaceList.size() - 1;
        reflectedState = startState + 1;
        transmittedState = -1;
    }

    for(int i = 0; i < nSamples; i++) {
        vec3 direction(startingPosition);
        int state = startState;
        interfaceList.prepareForSample();

        while(state != reflectedState && state != transmittedState && state != absorbedState) {
            const ABMInterface &interface = interfaceList.getInterface(state);

            double n1;
            double n2;
            double perturbanceReflect;
            double perturbanceRefract;
            int reflectState;
            int refractState;
            double thickness;
            double absorption;
            vec3 normal(0,0,0);

            if(direction.z < 0) {
                normal.z = 1.0;
                n1 = interface.nAbove;
                n2 = interface.nBelow;
                perturbanceReflect = interface.perturbanceDownAbove;
                perturbanceRefract = interface.perturbanceDownBelow;
                refractState = state + 1;
                reflectState = state - 1;
                thickness    = interface.thicknessAbove;
                absorption   = interface.absorptionAbove;
            } else {
                normal.z = -1.0;
                n1 = interface.nBelow;
                n2 = interface.nAbove;
                perturbanceReflect = interface.perturbanceUpBelow;
                perturbanceRefract = interface.perturbanceUpAbove;
                reflectState = state + 1;
                refractState = state - 1;
                thickness  = interface.thicknessBelow;
                absorption = interface.absorptionBelow;
            }

            double normalAngle = -direction.Dot(normal);
            if(thickness > 0 && freePathLength(direction, normal, normalAngle, absorption, disableSieve) < thickness) {
                state = absorbedState;
                break;
            } else {
                if(RANDOM_FUNCTION() < fresnellCoefficient(direction, normal, normalAngle, n1, n2)) {
                    state = reflectState;
                    direction = reflect(direction, normal, normalAngle);
                    if(perturbanceReflect != INFINITY) {
                        direction = brakkeScattering(direction, perturbanceReflect);
                    }
                } else {
                    state = refractState;
                    direction = refract(direction, normal, normalAngle, n1, n2);
                    if(perturbanceRefract != INFINITY) {
                        direction = brakkeScattering(direction, perturbanceRefract);
                    }
                }
            }
        }

        if(state == reflectedState) {
            numReflected++;
        } else if(state == transmittedState) {
            numTransmitted++;
        } else {
            numAbsorbed++;
        }
    }
    return ReflectPair((double)numReflected / nSamples, (double)numTransmitted / nSamples);
//.........这里部分代码省略.........
开发者ID:cosbynator,项目名称:ABM-U-and-ABM-B-CPP,代码行数:101,代码来源:run_abm.cpp


注:本文中的InterfaceList::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。