triangle

计算triangle sdf

点点圈 提交于 2019-12-01 20:50:21
发现Houdini行列式竟然会出问题????有人测试过matrix2吗。。。。。 float area_tri(vector2 a, b ,c){ float m11 = b.x - a.x; float m12 = c.x - a.x; float m21 = b.y - a.y; float m22 = c.y - a.y; // THIS WILL CAUSE ERROR ----- //matrix2 m = set( m11,m12,m21,m22) ; //float area = determinant(m); //return area * 0.5f; // THIS WILL CAUSE ERROR ------ return 0.5f*(a.x*b.y + b.x*c.y + c.x*a.y -a.x*c.y - b.x*a.y - c.x*b.y); } // int in_tri(float abs_AF,abs_BT,abs_GM) { if (abs_AF > 0.99999f) return 0; if (abs_BT > 0.99999f) return 0; if (abs_GM > 0.99999f) return 0; if( abs_AF + abs_BT +abs_GM> 1.0f) return 0; return 1; } //

作业练习1最终

て烟熏妆下的殇ゞ 提交于 2019-12-01 10:16:33
#include <studio.h> void main int a, b, c; scanf("%d,%d,%d", &a, &b, &c); if(a+b>c&&a+c>b&&b+c>a; if(a==b&&a==c) printf("equilateral triangle\n") else if (a==b||a==c||b==c) printf("isoceles triangle\n") else printf("triangle\n") else printf("non-triangle\n") system("PAUSE>NUL") return 0; 来源: https://www.cnblogs.com/zhang-shu-heng/p/11679898.html

每日一题_191011

孤街醉人 提交于 2019-11-30 23:09:16
如图所示,在平面四边形 \(ABCD\) 中, \(AB=1\) , \(BC=2\) , \(\triangle ACD\) 为正三角形,则 \(\triangle BCD\) 面积的最大值为 \(\underline{\qquad\qquad}\) . 解析: 将 \(BC\) 边固定,则 \(A\) 点在以 \(B\) 为圆心, \(1\) 为半径的圆上运动, 由于 \(\triangle ACD\) 为正三角形,因此 \(D\) 点是在以 \(E\) 点为圆心, \(1\) 为半径的圆上运动,其中 \(E\) 点是把 \(B\) 点绕着 \(C\) 点逆时针旋转 \(60^\circ\) 所得的点.因此显然当 \(D\) 点位于圆 \(E\) 的上端顶点时, \(\triangle BCD\) 的面积最大,且此时面积最大值为 \[ S=\dfrac{1}{2}\cdot |BC|\cdot \left(\dfrac{\sqrt{3}}{2}|BC|+1\right)=\sqrt{3}+1.\] 来源: https://www.cnblogs.com/Math521/p/11644090.html

导数求函数最值

眉间皱痕 提交于 2019-11-30 15:11:44
导数求函数最值 本文作者@guodongLovesOi 没有将导数用法规范,如果被数学老师打作者概不负责 首先对于二次函数 \(f(x)=x^2+3x+1\) 我们可以很方便的求出导数: \[ 设 \triangle=\lim_{\triangle->0} ,x'=x-\triangle\\ 那么f'(x)=\frac{f(x)-f(x')}{x-x'} \\ 即 \\ \frac{x^2+3x+1-{x'}^2-3x'-1}{x-x'}= \\ \frac{(x+x')(x-x')+3(x-x')}{x-x'}=\\ 即 \quad{2x+3} \] 设定点为坐标为 \((v,f(v))\) ,由图可知,在 \(f'(v)=0\) \(\therefore v=-\frac{3}{2}\) 将 \(v\) 代入: \[ (-\frac{3}{2},{(-\frac{3}{2})}^2-3\times \frac{3}{2}+1)\\ (-\frac{3}{2},-\frac{5}{4}) \] 通过可爱的顶点式可以验算上面是对的。 那么扩展到二次函数 \(f(x)=ax^2+bx+c\) \[ 设\triangle=\lim_{\triangle->0},x'=x-\triangle\\ 所以f(x)的导数f'(x)可以这样计算:\\ \frac{ax^2+bx+c-a{x'}

120. Triangle

纵然是瞬间 提交于 2019-11-30 13:55:58
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the following triangle [ [2], [3,4], [6,5,7], [4,1,8,3] ] The minimum path sum from top to bottom is 11 (i.e., 2 + 3 + 5 + 1 = 11). Note: Bonus point if you are able to do this using only O ( n ) extra space, where n is the total number of rows in the triangle. class Solution { public int minimumTotal(List<List<Integer>> triangle) { int[] p = new int[triangle.size() + 1]; for(int i = triangle.size() - 1; i >= 0; i--){ for(int j = 0; j < triangle.get(i)

E. Generalized Pascal's Triangle(National Contest for Private Universities (NCPU), 2019)

╄→尐↘猪︶ㄣ 提交于 2019-11-30 05:46:00
题目链接 INPUT 2 3 4 OUTPUT 1 2 2 1 2 1 1 3 3 3 6 3 1 3 3 1 1 4 4 6 12 6 4 12 12 4 1 4 6 4 1 题意:输出第n个图所对应的矩阵。 思路:找规律。每一个结点都是由上一个图中三个结点的相加而来。直接打表求解即可。 #include <algorithm> #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <queue> #include <stack> #include <map> using namespace std; #define MAX 1e9+7 #define inf 0x3f3f3f const int maxn=1e4+10; typedef long long ll; int s[25][25][25]; int main() { s[0][1][1]=1; for(int i=1; i<=20; i++) { for(int j=1; j<=i+1; j++) { for(int k=1; k<=j; k++) { s[i][j][k] = s[i-1][j-1][k-1] + s[i-1][j-1][k] + s[i-1][j][k]; } } } int n;

@ContextConfiguration注解说明

泄露秘密 提交于 2019-11-29 21:01:59
https://juejin.im/post/5ce5effb6fb9a07f0b039a14 前言 小伙伴们是否想起曾经被 SSM 整合支配的恐惧?相信很多小伙伴都是有过这样的经历的,一大堆配置问题,各种排除扫描,导入一个新的依赖又得添加新的配置。自从有了 SpringBoot 之后,咋们就起飞了!各种零配置开箱即用,而我们之所以开发起来能够这么爽, 自动配置 的功劳少不了,今天我们就一起来讨论一下 SpringBoot 自动配置原理。 本文主要分为三大部分: SpringBoot 源码常用注解拾遗 SpringBoot 启动过程 SpringBoot 自动配置原理 1. SpringBoot 源码常用注解拾遗 这部分主要讲一下 SpringBoot 源码中经常使用到的注解,以扫清后面阅读源码时候的障碍。 组合注解 当可能大量同时使用到几个注解到同一个类上,就可以考虑将这几个注解到别的注解上。被注解的注解我们就称之为组合注解。 元注解:可以注解到别的注解上的注解。 组合注解:被注解的注解我们就称之为组合注解。 @Value 【Spring 提供】 @Value 就相当于传统 xml 配置文件中的 value 字段。 假设存在代码: @Component public class Person { @Value("i am name") private String name; }

LeetCode 611. Valid Triangle Number

依然范特西╮ 提交于 2019-11-29 18:05:51
和3Sum那题非常类似。3Sum我们是固定i,令j=i+1, k=n-1。 本题由于三角形需要两边之和大于第三边,nums[i]+nums[j]>nums[k]。因此我们可以固定k,令i=0, j=k-1。 如果nums[i]+nums[j]>nums[k],说明 [i,j-1] 范围内的所有数作为i,加上j和k都是可以的。 反之如果nums[i]+nums[j]≤nums[k],那我们必须增加nums[i],和才会增大。 class Solution { public: int triangleNumber(vector<int>& nums) { int n=nums.size(); int res=0; sort(nums.begin(),nums.end()); for (int k=n-1;k>=0;--k){ int i=0, j=k-1; while (i<j){ if (nums[i]+nums[j]>nums[k]){ res += j-i; --j; }else{ ++i; } } } return res; } }; 时间复杂度 O(n^2) Reference https://leetcode.com/problems/valid-triangle-number/discuss/128135/A-similar-O(n2)-solution-to-3-Sum

css 利用border 绘制三角形. triangle

依然范特西╮ 提交于 2019-11-29 15:50:59
1.基础三角形. 1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>全局css以及辅助css</title> 6 <style type="text/css"> 7 8 9 10 /***1: 初始样式设置*******/ 11 html, body, ul, li, ol, dl, dd, dt, p, h1, h2, h3, h4, h5, h6, form, fieldset, legend, img, div,span, table,th,tr,td,button { margin:0; padding:0; } 12 13 14 15 16 /*******2: 清除浮动******/ 17 18 /*IE6, IE7 生效*/ 19 .floatfix{ 20 *zoom:1; 21 } 22 23 /*其他浏览器*/ 24 .floatfix:after{ 25 content:""; 26 display:table; 27 clear:both; 28 } 29 30 /***3: 超出长度显示省略号. 还需要设置width**/ 31 32 .ellipsis { 33 text-overflow: ellipsis; 34 overflow:

用css绘制三角形

三世轮回 提交于 2019-11-29 15:50:26
#triangle-up { width: 0; height: 0; border-left: 50px solid transparent; border-right: 50px solid transparent; border-bottom: 100px solid red; #triangle-down { width: 0; height: 0; border-left: 50px solid transparent; border-right: 50px solid transparent; border-top: 100px solid red; #triangle-left { width: 0; height: 0; border-top: 50px solid transparent; border-right: 100px solid red; border-bottom: 50px solid transparent; } #triangle-right { width: 0; height: 0; border-top: 50px solid transparent; border-left: 100px solid red; border-bottom: 50px solid transparent; #triangle-topleft { width